January 2008 - Posts
I want to use snippets rather than clumsy typing during my talk at the Victoria .NET code camp on Saturday. New to snippets, I read the online documentation about accessing the Code Snippets Manager. Go to Tools --> Code Snippets Manager they say. Easy, right? Nope! I don't have that item in VWD. Does anyone else?
Sheesh! I thought I had the default Web development settings in Visual Studio 2008's Visual Web Developer environment.
At any rate, unable to find a way to open the Snippets Manager from a menu, I went into the keyboard mapping scheme for hints and searched for commands containing "snippet". Sure enough, up came Tools.CodeSnippetsManager, currently assigned to Ctrl+K, Ctrl+B. I used the shortcut chord and realized that have never seen that snippet tool before!
If you're like me and don't have Tools --> Code Snippets Manager in VS 2008 VWD, do this:
From the Tools menu, click Customize.
- In the Categories list, click Tools.
- With the Customize dialogue box still open, open the Tools menu.
- Back in the Customize dialogue box, in the Commands list, drag Code Snippets Manager and drop it on the Tools menu.
- Click Close on the Customize dialogue box.
Why am I the last person on Earth to discover things like this? <grin>
One of my client's customers was really upset because Internet Explorer 6 would often hang on opening the client's ASP.NET Web application. Naturally it struck during an important "show and tell" session.
We were able to reproduce the problem by deleting all of the temporary files, history, cookies and web form info in IE 6 and then browsing to the page. (This became known as the "Virgin IE Loading" bug!)
IE 6 has a bad reputation for choking on compressed content and I suspected that a regression error had crept back in during an update. Our first attempt was to disable gzip compression in IIS 6. No luck. IE 6 still hung. Then, I saw a post about AJAX compression issues.
Although the post makes it sound like ASP.NET AJAX uses compression only for IE 7, we decided to disable script compression using this setting in the web.config:
<system.web.extensions>
<scripting>
<scriptResourceHandler enableCompression="false" enableCaching="true"/>
</scripting>
</system.web.extensions>
That was it! Fixed!
I'm not one who supports Microsoft "owning" every machine on the planet when it comes to forced Windows Updates but I'm willing to make an exception if there's a way to get IE 7 pushed out to this client sooner than later. Some corporations move at such a snail's pace. <grin>
I went around and around for several days on the case of the disappearing treeview. My client is using the excellent ComponentArt TreeView control wrapped inside an ASP.NET AJAX UpdatePanel with a Timer control to update the treeview contents every minute.
The treeview worked perfectly on a full page load but disappeared when the timer caused a partial page update. The scene was further complicated because there's a splitter pane or two involved.
I enlisted my friends at ComponentArt (I wrote their early documentation) and worked with Developer Support manager Stephen Hatcher* on and off for two weeks. We tried various scenarios and builds to fix or reproduce the problem.
It turns out that the issue had nothing to do with the control. Somewhere up the line, perhaps in the Web hoster's machine.config, the ViewState had been switched off. When the timer triggered a postback, the controls lost their "memory".
My "eureka" moment came when I analyzed the ViewState contents with Fritz Onion's ViewStateDecoder 2. The weird thing is that even when ASP.NET ViewState is off, there's still evidence of a viewstate in the page such as:
id="__VIEWSTATE" value="/wEPDwULLTE4OTU2NjkzNjBkZNwIdjnYZTJa5tc5V8uEAO47U+LR" /
The fix was to insert the following in the web.config:
<pages enableSessionState="true" enableViewState="true"
enableViewStateMac="true"
validateRequest="true">
</pages>
The preceding will either throw "It is an error to use a section registered as allowDefinition='MachineOnly' beyond machine.config" or (perhaps) enable the ViewState. Fortunately, it did the latter. Problem fixed.
Oddly enough, the client contacted me here in Victoria because of a comment on my Web site that I enjoy ASP.NET troubleshooting... It pays to advertise, I guess.
Thanks again to ComponentArt for lots of free support time on this, even though the missing ViewState actually had nothing to do with their product.
*Although his name is Stephen, he's more than likely to have someone else's name on his shirt. He buys brand new (but inexpensive) clothes from a uniform supply company. If the shirt with the name "Jake" sewn on the chest didn't fit Jake, the rejected item might show up on Stephen next week!
Sheesh! I had a nasty shock yesterday when I went to register for the Vancouver Launch & Technical Readiness event on March 4th - it said the event was full! What?!?! Already?!?!
It turns out it was a glitch at the Web site and the "full" message was bogus. I was able to register this morning without difficulty so you should be okay too.
However, that serves as a warning that these free events fill up quickly. For the Canadian events, register at http://www.microsoft.com/canada/heroeshappenhere/register/default.mspx.
BTW, I'll be in Vancouver with a number of other MVPs to answer questions in the Ask the Experts booth in the Community area of the event. I'll also be at the Community Connection event in Victoria on March 5th.
Tagged!

I suspect that most ASP.NET developers would like to get started with Silverlight development. For most of us, it's a question of finding the time, overcoming some inertia, and getting over a touch of anxiety about the learning curve. Adam Nathan's Silverlight 1.0 Unleashed is a good way to get your fingers into Silverlight code and feel your way around - much the way you did when you first encounter any new platform.
Keep in mind that this is a book for developers who prefer to work directly in code and markup. If you expect instructions on how to direct a graphical interface to generate the XAML and JavaScript, you'll be disappointed: this is not an Expression Blend book.
A couple of observations worth noting at the outset: First, this Unleashed book is a manageable size! I don't recall a book in this series weighing in at under 300 pages. A smaller book is far less intimidating for beginners. Secondly, the book is in colour, including the syntax highlighting. Colour enhances the readability of any computer book, especially one that deals with such a visual topic.
The author establishes a rapport with developers early in the book. For example, in "A Note for Those Afraid of JavaScript", he recognizes that many of us aren't enthused about being "forced" to use JavaScript in Silverlight 1.0. On the positive side, he points out that Silverlight limits your exposure to the differences in browser DOMs that make JavaScript on the client a pain. And, like most of us, he looks forward to Silverlight 2.0's support for .NET languages even while offering a 1.0 book.
You notice Adam Nathan's expertise and enthusiasm in the world of XAML on every page. For example, in the chapter on Brushes and Images, he shows how to use the VideoBrush object to paint a block of text with live video. The rest of us wouldn't know where to start to implement these effects - or even that they could be done by mere mortals. Despite being a Microsoft employee, Nathan doesn't gloss over Silverlight 1.0's limitations. His "warning" sidebar on image file formats points out that the 1.0 release doesn't support .gif or .bmp - you must use .png and .jpg. In a comparison with Flash, he notes Silverlight's lack of morphing, blurring, and glowing effects. That said, he offers helpful tips and workarounds where possible.
I'm of two (or three!) minds about how to approach Silverlight development. When I learned ASP Classic, it was all hand coding at the start. As the tools came along (Visual InterDev), development became much faster. But I could always fall back to hand coding when the tool couldn't do what I wanted or was just too slow. Should I take the same approach with Silverlight 1.0 - code by hand and then learn the graphical way? The trouble is, the graphic tool is here now and hard to ignore. I suspect that coding for Silverlight will be a hybrid process where you let Blend do the grunt work and then turn to Silverlight 1.0 Unleashed as a valuable reference for tweaking the code to get the exact effect.
I've learned a lot from Silverlight 1.0 Unleashed and plan to dig in further to create some animations for my new Web site. That said, I look forward to the day when I can build JavaScript-free Silverlight 2.0 apps in VB using Visual Studio.
I needed to compare the web.config files generated by Visual Studio for ASP.NET 2.0 and ASP.NET 3.5 projects. (In my opinion, web.config files are totally out of hand in ASP.NET 3.5, but that's another blog post.)
My search for a free Diff tool turned up SourceGear DiffMerge from the folks who make the fine version control software, Vault.
DiffMerge is a polished product for side-by-side comparison (and merging) of files. It highlights changes within the lines and has many configuration options.
As they say on the Pricing page, "It's FREE...Enjoy!"
If you get an error such as "The specified string is not in the form required for an e-mail address." when trying to initialize a System.Net.Mail.MailMessage object, look in the web.config file for errors in the mailSettings and smtp sections.
For more detail on how I discovered the solution (but a little late), check out my article at http://www.kencox.ca/ShowArticle.aspx?ID=21 .
Ken
MVP [ASP.NET]
I'll be speaking on the topic "LINQ: Simplifying Data Handling in ASP.NET" at the Victoria .NET CodeCamp on January 26th.
It's going to be a great (free!) day with expert presenters that include Beth Massi and Richard Campbell.
Here's the abstract for my beginner-level talk:
Language Integrated Query (LINQ) is a "learn once, use everywhere" language addition to VB and C# that makes it easy to query, sort, and filter .NET collections including SQL Server data. This presentation, based chapters from my book "ASP.NET 3.5 For Dummies", starts with the basic syntax of LINQ including the From, Select, Where, Aggregate keywords, the Skip and Take operators, and extension methods such as Count, Average, Min, and Max.
During the LinqDataSource control demonstration, you'll see how to use the new ListView control and DataContext object to build a very functional database-driven Web application in ASP.NET 3.5 and Visual Web Developer 2008 Express.
After my talk, you'll find some of the materials on my new Web site at http://www.kencox.ca/.
Although Visual Web Developer 2008 makes it convenient to connect to a remote site, doing so with the built-in FTP client is a pain in the butt. There's something wrong with the VS-embedded module that handles FTP transfers. Am I the only one seeing slow screen painting and refresh in this client app? It's like everything is working at quarter speed on a single thread. It comes to a dead stop for no reason.
It's unfortunate to see such a poor implementation dragging down a fine developer tool. It's not like FTP is new technology. My ancient version of WS_FTP is far more efficient than the transfer software in VWD 2008.
The Copy Web Site/FTP feature deserves a hotfix, and if that's not possible, I hope Microsoft can address it in the first Visual Studio 2008/Visual Web Developer service pack.
More Posts