Oct2010
14

ASP.NET Controls - System.Web.UI.HtmlControls.HtmlButton client click hits the server twice

by nmgomes

Hi all,

At work we have about 5000 PC's that are mainly our commercial network. All those PC use intranet services and web applications.

Until a few months ago IE6 was our corporate browser (yep) but we ended moving to IE8.

A few days ago someone came to me saying that their application appears to have some problem because every time they click some HTML buttons the server gets two hits.

Also they are able to say that this didn't happen when they used the IE6.

In the faulty application the buttons that trigger two posts were System.Web.UI.HtmlControls.HtmlButton controls with Click event handlers registered.

After some research I found that the default type attribute value for HTML BUTTON element has changed in IE8 and later (here).

  • In IE7 and earlier the default value is 'button'
  • In IE8 and later the default value is 'submit'

This changed in browser default behavior was not reflected in the Server-Control that renders it: it doesn't set the type attribute value to button when a postback is required.

Without such change, every time we attached a Click event handler to a HtmlButton we endup with two posts: one triggered by the _doPostback function and another from the form itself (caused by the default type='submit' value.).

I easily bypass this problem by setting the type attribute value to 'button' in my base control.

Even so, I think that this change should be done by the framework itself when a postback is required in a HtmlButton.

After some 'reflection' I propose changing the System.Web.UI.Util.WriteOnClickAttribute method to do the job.

Such change would ensure the some behavior independent of the browser version.

If you have another workaround or you think I'm completely wrong please let me know.

Also if you think this is a real problem that should be solved then visit this Connect entry I create.

Filed in: ASP.NET

Sep2010
18

jQuery UI on the Microsoft CDN

by nmgomes

Microsoft is now hosting jQuery UI on the Microsoft Ajax CDN (uncompressed and compressed versions) as well as all the pre-built themes.

Remember that CDN using is free and no registration is required.

For more information check out Stephen Walther’s announcement from Microsoft.

Filed in: ASP.NET

Feb2010
18

WinForms Controls – Displaying a vertical tab

by nmgomes

It’s been several years since my last WinForms programming experience - I’m a ASP.NET maniac since 2002/2003 – but this year started with an unexpected challenge: build a Visual Studio  2008 Integration Package (VSIP) with an advanced Editor for some in-house metadata xml structure.

If you already did some work related to VSIP is no surprise that I was forced to embrace the long ago forgotten Winforms controls specificities.

Maybe I simply forgot or never noticed before, but the TabControl when operating in vertical mode – either Left or Right – display an amazing poor user experience and in most cases text are not showed.

Ok, no big deal, TabControl have enough extensibility points to enable us to work around and its even available a Msdn article with the recipe: How to: Display Side-Aligned Tabs with TabControl.

Maybe it’s just me but this is the kind of behavior I did expect to be fully available and functional since it seams to be quite common in most applications.

Filed in: WinForms