in

ASP.NET Weblogs

Andy Smith's Blog

Page.RegisterStartupScript('Andy', 'MetaBuilders_WebControls_GainKnowledge();');

my masterpages and the __doPostBack bug

Doug Reilly recently blogged about his problem of running into the v1.1 __doPostBack bug, mentioning that my version of MasterPages isn't affected by it. I really debated about including my own little bugfix into the distribution, but after some consideration, I decided to include it. Microsoft has a fix for the bug, but it's a bit of a hassle to get it, calling phone numbers and such. So a few 3rd-parties have released their own fixes to this bug, usually regex or something to alter the output of pages to change the __doPostBack script itself. I looked at the problem from the other way, changing the behavior of the HtmlForm control so it doesn't expose the bug. Basicly, because the name of the form has a colon in it from being in a naming container, it's no longer a valid jscript identifier. I figured, hey, if I just make the name attribute not have a colon, that fixes the problem too... no need to futz with generated script. This way, there is no problem with using my masterpages with either patched or unpatched systems. I wrapped the idea in a NoBugForm control, which I include in my version of masterpages. It derives from HtmlForm, so everything in the page framework functions just like it should. Simply replace the form tags with NoBugForm tags.

Comments

 

Paul Wilson said:

My version of MasterPages also doesn't have this problem, since it avoids the naming containers that causes the problem:

http://www.aspalliance.com/PaulWilson/Articles/?id=14
August 28, 2003 6:01 PM
 

IranASP.NET Webmaster said:

Hi Andy,

It helps me so much.

Thank you and keep continue blogging!

Regards,
Sassan
September 13, 2003 6:14 AM
 

alan said:

thanks dude for the fix -
September 17, 2003 9:27 PM
 

matt said:

Andy,
Nice work on the MasterPages and the nobugform...they work great! We are starting to re-wrap our websites with the new master page templates and found that we have some client-side JavaScript that is incompatible with the MasterPages framework. We have written some of the client-side JavaScript code with the following syntax:


document.getElementById("txtRegStartDate").value


We get object reference not found errors on the client-side. My hunch is that the document.getElementById...reference is not correct or cannot find the referenced control by the id...

Any suggestions would be helpful. Thanks!

Final Note:
We are using it on a web application that can contain one or more ASP.Net web applications. We created a separate web application just for our MasterPage controls. Installed the MasterPage assembly into the GAC. Then we created "virtual" directories for each of our web applications (root and sub-root), and pointed it to the MasterPage web application. In our web pages we use the "~/MasterPageSite/template.ascx" to reference the templates from the MasterPage application. We did this to work around the server error when trying to use controls from another web application. This works great.

June 29, 2004 11:51 AM
 

Anders V. said:

How is it possible to add another form tag when the NoBugForm already is present? Im trying to add a form which use GET instead of POST.

Best,
Anders
July 10, 2004 1:35 PM

Leave a Comment

(required)  
(optional)
(required)  
Add