October 2005 - Posts - Jon Galloway

October 2005 - Posts

Installing Windows Vista October CTP (Build 5231) on VPC with VM Additions

I installed the Windows Vista October CTP (Build 5231) on Virtual PC yesterday. There were a few gotchas that I thought I'd share in case it saves anyone else some time.
  1. Virtual PC can't capture an ISO image greater than 2.2 GB, so you need to use something like Daemon Tools on your host machine to mount the ISO as a virtual drive, then capture it as a physical drive in VPC.
  2. Vista won't install on a RAW partition, which is what an unformatted VPC Virtual Hard Drive (VHD) image gives you. You can do some tricky commandline DISKPART stunts, or you can just create the partition in the install process knowing that Vista still won't like it, reboot the VPC instance, and this time VPC will recognize the partition it created. I went with the second option.
  3. This Vista build can't access Windows Update. You just get a message saying you need to use Automatic Updates and tells you how to set that up. Knowing that unpatched machines on the net can get haxxor'd in 20 minutes on average, I set the Auto Update time to the next hour and disabled the VPC network connection until that time. Silly me, there weren't any Auto Updates since it had just been released, but I still think minimizing Internet time before patching a machine is the best plan.
  4. The VPC VM Additions Installation hangs on this Vista build, and the graphics are absolute hell without them (640x480 at 8 bit, I believe). The trick is as follows: leave the hung installation running, go into the Control Panel and remove the VGA Display Driver, and say Okay when prompted to reboot. When the system comes back up, you'll have the state of the art S3 Trio display driver. It got wiggy on me when I tried to change the Display Resolution, so I rebooted again and was able to change the resolution and things were great. Dog slow, but great. If you cancel the install or kill the wrong msiexec process, the install rolls back and the drivers get removed, causing the magic not to happen.
  5. I kind of lied about the VM Additions. The video drivers are installed, and they make a big difference, but the rest of the VM Additions aren't installed. That means no folder sharing, etc. They might release VM Additions for Vista Beta 1, but I'm not holding my breath.
I'll leave it to the pundits to describe what's new in this build, but the most interesting things for me so far are WMP 11, Media Center Vista (which it sounds like is going to be inclueded in Vista, no longer a separate product), and the latest IE7 build.
Posted by Jon Galloway | with no comments
Filed under:

How exactly would you like me to "Quote values differently inside a '<% ... "value" ... %>' block"?

Visual Studio freaks out when your HTML contains nested quotes. Roy's solution (using single quotes for the attribute and double quotes for the databinder or function arguments) works unless you need to nest quotes, which occurs if you're including a Javascript call in a databinding statement:

<asp:TemplateColumn>
    <ItemTemplate>
        <
href="javascript:showPopup('\Popups\Edit.aspx?ID=<%# DataBinder.Eval(Container.DataItem,"itemID")%>')">edit</a>
    <
/ItemTemplate>
<
/asp:TemplateColumn> 

The problem here is that you need quotes around your href attribute, quotes around your javascript function argument, and quotes around your DataBinder.Eval string parameter. Tim sums it up pretty will here, but you're pretty much stuck with either  "Quote values differently inside a '<% ..."value"... %>' block." or "Place quotes around a '<% %>' block used as an atribute value or within a SELECT element." I haven't seen a good discussion on how to handle this well, so here's what I've come up with - please recommend something else if you've got a better solution.

We need a third quote, right? Well, one common solution is to use \u0022 - the VS UI doesn't see it as a quote and doesn't get confused, but the ASP.NET rendering engine writes it out as a quote:

<asp:TemplateColumn>
    <ItemTemplate>
        <
href ="javascript:showPopup(\u0022\Popups\Edit.aspx?ID=<%# DataBinder.Eval(Container.DataItem,"itemID")%>\u0022)">
        
edit/a>
    <
/ItemTemplate>
<
/asp:TemplateColumn> 

A better solution is to just escape the quote with a backslash (\"). The VS IDE handles that just fine:

<asp:TemplateColumn>
    <ItemTemplate>
        <
href ="javascript:showPopup(\"\Popups\Edit.aspx?ID=<%# DataBinder.Eval(Container.DataItem,"itemID")%>\")">
        
edit/a>
    <
/ItemTemplate>
<
/asp:TemplateColumn> 

Another solution is to use code behind to actually construct the links. I normally wouldn't use that unless there was a good amount of formatting, and even then you can get away from that with a format string in the DataBinder.Eval call. I usually see people recommend one-off functions for that kind of thing, but I prefer using something more generic. The following function will work in a page code behind, but could be made a static function and placed in a code library class: 

protected string BuildJavascriptLink(string format, params string[] input)
{
    format = format.Replace("{quote}","\"");
    
string retval = string.Format(format,input);
    retval = retval.Replace("'","\"");
    
return retval;
}

Now we could reference it in the code front with something like this:

<href='<%# BuildJavascriptLink("javascript:showPopUp({quote}/PopUps/{0}{1}{quote},{2},{3})","StreetLevelMap.aspx?ID=",Convert.ToString(DataBinder.Eval(Container.DataItem,"Entity_ID")),"600","450") %>'>Street Map</a>

Posted by Jon Galloway | with no comments
Filed under:

[link] Connecting to Terminal Services When All Active Sessions are Used

Here's a little trick for getting into a box via Terminal Server when all sessions are in use. Phil and I came up with it yesterday and I was going to write it up, but he beat me to it with a pretty nice writeup. Here it is:
We use Remote Desktop (Terminal Services) to remotely manage a Windows 2003 server that is not part of our domain. Recently we ran into the two user limit for remote desktop connections, which barred anyone from connecting. Jon discovered a neat little trick that got us in. He ran the following command from the command line: mstsc -console It turns out that mstsc.exe is the remote desktop connection application. The -console flag specifies that we want to connect to the console session of a server. Since we generally launch Remote Desktop from the icon, we almost always leave this console session free. Nice! ... [via haacked - Connecting to Terminal Services When All Active Sessions are Used]
Posted by Jon Galloway | 3 comment(s)
Filed under:

BizTalk is to Windows Workflow Foundation as...

Nice to see this spelled out.

So what about BizTalk and Windows Workflow Foundation? Did you bet on the wrong horse by choosing BizTalk Server? No you didn't. BizTalk Server is, was, and will be the right architecture for business process and integration on Windows. To properly serve the needs of business process and integration you need a "man in the middle" server that adapts, routes, tracks, manages, scales and has all the appropriate BPM capabilities such as BAM. Windows Workflow Foundation gives you none of that. On the other hand there are many scenarios that Windows Workflow Foundation is useful outside of business process and integration such include page-flow in ASP.NET web applications, workflow within line of business applications that ISVs build, workflow within Office. By targeting ISVs primarily the Windows Workflow Foundation technology can be embedded within these applications.

Put simply:

A. Workflow within applications = Windows Workflow Foundation< BR > B. Workflow across applications = BizTalk Server

Source: What about BizTalk Indeed?

Posted by Jon Galloway | with no comments
Filed under:

[links] Recent links of interest - 10/8/2005

Here are some interesting links from the past month or so. Some of these will be old news if you read all the .NET blogs; some of my readers don't.

---- .NET / Development ----

.NET Disassemblers and Decompilers - Jason Haley assembled some great references for his Code Camp presentation. [via Jason Haley]

Mono ECMAScript (Javascript) compiler (PDF) - Some cool info on how they're implementing dynamic language concepts in .NET. You can read more about the Mono ECMAScript project here. [via Andrew Stopford's Weblog ]

Ocelot database - [via Enjoy Every Sandwich ]

Google Reader - [via Jason Salas ]

OutPost: PostBack Over XmlHttp - Interesting approach to AJAX style development that avoids some of the problems the Javascript -> weservices approach creates, like state management [via Larkware]

App_Offline.htm - cool feature in ASP.NET 2.0 - if this file is present, the appdomain will spin down and all requests will redirect to that page. [via Erik Porter]

GhostDoc 1.3.0 Released - This tool keeps getting better and better. Check out this 4 minute GhostDoc overview video if you haven't used it. [via HAACKED]

Attend Microsoft Launch Event, Get Visual Studio 2k5 and SQL 2k5 free  - [via Slickdeals.net]

Absolutely free Windows software - Pretty good list. I think I've used about half of these. I'm trying out Ditto now. This list is a good complement to the Computer Zen Ultimate Tools List . [via help.net]

DevAge Source Pack - Beta 2  - I reviewed Source Pack Beta 1 a while ago. Looking forward to the release. [via DevAge Products News ]

JRX - Realtime Javascript RegEx evaluator  - what it says.

PureText - A lot of people have linked to this one. Finally installed it. Nice.

Cerkit Art - Michael's been going to town with Microsoft Expression.

---- Community ----

Microsoft Codename Spang  hoax - Glad I didn't waste any time on this. Sounded supiciously like Boa. Now, without making too big a deal about this, I think this kind of thing is precisely the opposite of what MVP's should be doing. Technical leadership, especially in today's internet article / blog driven environment, is all about trust and credibility. A hoax is an abuse of trust and reduces credibility. Michael Earls' response to the Boa hoax  applies. And, couldn't you come up with a better name than "Spang"? Seriously. Use a codename generator next time.

---- Fun ----

Snakes on a plane (!!!) - Samuel L. Jackson has signed on to this exciting film project, and is committed to the core values that will make it a classic. Get the Snakes on a Plane T-Shirt now. Enjoy the flight, Mr. ... Snakerson.  [via Preshrunk]

Einstein's Riddle - Except Einsten didn't actually write it . Well, it's still fun. Further info and solution here . [via OptionScalper ]

Web 1.0 Summit Photos  - sounds like this went well. [via Laughing Squid

Posted by Jon Galloway | with no comments
Filed under:

Uninstall a Previous Application When Upgrading an Application with Setups Created in VS.NET

Uninstall a Previous Application Installation When Upgrading an Application with Setups Created in VS.NET - The Code Project - .NET

"How to uninstall a previous application install during an upgrade with VS.NET created setups is a question that frequently appears in the forums. No matter what options you select in the VS IDE when you create a new setup for an upgraded application, it still never uninstalls the existing application!

One thing that most developers are not aware of is how to properly use the Update Code, which is what triggers an uninstall of a previous version. Windows Installer includes the capability to find and uninstall previous versions of an application. But there are some steps required that are not well documented in VS.NET to make this happen...

Source: Uninstall a Previous Application When Upgrading an Application with Setups Created in VS.NET

The uninstall / install routine is one thing that's always bugged me about the free / open source VS.NET goodies with MSI installs (IMHO Instant Blogger, RSSBandit, etc.)  Of course, you can just go with something like Inno Setup , which does a pretty nice job with upgrades.

Posted by Jon Galloway | with no comments
Filed under: ,

Office 12 will have Native PDF support (or, rather, no...)

Steven Sinofsky (SVP, Office) announced Saturday that Office 12 will have native PDF support.

UPDATE June 2006 - Adobe's pressured them to remove it from the product; it will hopefully be available as a free download.

Sure, there are plenty of /. style comments to be made on how most users would have ranked this feature a little higher than Clippy in the Office roadmap, and that the free OpenOffice has supported PDF for a while now. Sure enough, /. picked this up and the original announcement post has plenty of slasher angst-ridden comments.

I'm just happy to see this feature included. Office 12 is really shaping up to be a significant upgrade, which is hard to do with version 12 of anything.

I'd like to see PowerPoint export of SWF, as OO does.

In the meantime, there are plenty of free options for creating PDF's from Office[1]:

  • I use PrimoPDF, a free PDF print driver
  • CutePDF uses the opensource GhostScript (a pdf suite of tools), You do not need to install Ghostscript
  • PDFCreator is an open source option

Got a PDF alternative you'd like to recommend?

[1] from Don Good - thanks!

Posted by Jon Galloway | with no comments
Filed under:

[asp.net] Simple utility function to return all selected values from a CheckBoxList

The ASP.NET CheckBoxList.SelectedValue property only returns first item selected. The MSDN solution is ugly - iterate the CBL items checking each one to see if it's selected.

Five minutes of Google-Fu didn't turn up anything, so here's a simple utility function to get a string array of selected values.

public string[] CheckboxListSelections(System.Web.UI.WebControls.CheckBoxList list)
{
 ArrayList values = 
new ArrayList();
 
for(int counter = 0; counter < list.Items.Count; counter++)
 {
  
if(list.Items[counter].Selected)
  {
   values.Add(list.Items[counter].Value);
  }    
 }
 
return (String[]) values.ToArray( typeofstring ) );
}

Posted so:

  1. I can find it later
  2. I can maybe save the next guy some time
  3. The piranha haters community can point out how this could be done better.
Posted by Jon Galloway | 1 comment(s)
Filed under: ,

JavaScript only pretends to support function overloading

I frequently use method overloading a lot in my C# code to allow optional parameters, so when I wanted to implement a simple popup function with optional support for virtual root and website based on the url, here's what I came up with:

function showPopUp(virtual, url, height, width)
{
 
if(location.pathname.indexOf(virtual)>=0)
 { 
  
//we're running in the virtual root, so prepend it to the url
  
url=virtual+url;
 }
 showPopUp(url, height, width);
}

function showPopUp(url, height, width)
{
 window.open(url, 
'PopUpWindow''toolbar=no,directories=no,menubar=no,resizable=no,status=no,height=' + height + ',width=' + width);
}

Javascript sneakily pretends to support this - no script error - every time I called the function, the virtual root wasn't being added on. That's because Javascript doesn't support method overloading; it just uses the function which was defined last (thanks, Bertrand, for verifying my hunch). I had to give the second function a different name, and it all worked.

Here's an easy way to verify - this will show the second message:

<html>
<
head>
<
script>
function test(one,two)
{
alert('expected: first function with two parameters');
}

function test(one)
{
alert('surprise! second function with one parameter');
}
</script>
<
/head>
<
body onload="javascript:test('first','second')">
<
/body>

 

More Posts « Previous page