ASP.NET 2.0 does great things but like its ancestors also has holes: things we need to do but can't -- or can't without dodging around it with inside knowledge, JScript and other tricks. AspNet2Holes is about those holes and the ways to step around them.

Sunday, September 03, 2006

Conveniences of controls

As one of its undisclosed "features" ASP.NET 2.0 will conveniently inhibit control events when you try to use "too many" of them. For example, suppose you need to confirm a user action and also validate that the user has specified an action to take. You might think you could use a standard approach -- a JavaScript function for OnClientClick with a Button and a RequiredFieldValidator in the < body > section of your .aspx file:

Apparently Microsoft doesn't think your users should be bothered with "too many" messages, so ASP.NET 2.0 will conveniently inhibit the ValidationSummary, and no popup message will appear. One solution is to take out the validators and provide your own validation in JavaScript, for example:

About Me

Craig BolonCommercial software development over 25 years in Windows and Linux, before that in DOS, Unix, VMS and several others, more than 20 languages. Working now mostly in ASP.NET with C#, SQL and JavaScript.
View my complete profile