MasterPage Ultra Serious BUG - will lead to controls with regular incidents in the form - and solutions

zhaozj2021-02-16  88

This question has been published on the MSDN, and its phenomenon is:

When the user accesses 1, use the MasterPage's web form 2, and the form contains a web server-side control with a rapid event (such as linkbutton, which is very common, there is too much in DataGrid) So 1 1 When the page is open, the IE will report the JavaScript script error - I look forward to ";" 2, click on the web server-side control (such as page pages), IE, IE will prompt the script error again. - The first line of the first character, the object is not defined - there will be no response (no return)

After multiple verification comparisons, this problem is found in the client page generated by the Web Form, where the root source is finally generated, in which the __dopostback function.

We know (don't know if you can go to the relevant website to find information) ,. Net Framework generates a client back-to-feet function for the control in the form --__ dopostback - it is responsible for the client's event and included The parameters are submitted with the client form with a certain format. The problem is in this function.

This function is normal when you don't use MasterPage. There is a code like this inside it:

Theform = document.form1; // Form1 is the only server-side form (Runat = Server Method = POST) in the web form, which is also the Web Forms specified by .NET Framework 1.0 / 1.0.

When we use MasterPage, the code will change:

Theform = Document.contentContainer1: _ctl0: form1; // Form or Form1, just uses MasterPage, masterpage will put Form1 in ContentContainer, resulting in such control parent and child relationships. This relationship also makes the Form1 becomes a ContentContainer1__ctl0_form1, which changes it to ContentContainer1: _ctl0: Form1. Those familiar with JavaScript should know that when the control name is: or other special characters, only the "Document. Control Name" will cause script errors.

This consequence is obviously unable to solve it through ordinary technical means. I want to solve this problem with this problem only from .NET Framework or MasterPage itself. For the former, we have no intervenes (built-in masterpage .NET Framework 2.0 will not set this serious bug, Microsoft will also significantly improve the entire framework in many ways). Fortunately, many masters have been amended to masterpage, and WilsonMasterPages is a masterpage alternative I found. This is its webpage:

http://authors.aspalliance.com/paulwilson/articles/?id=14

Note: In the above address, WilsonMasterPages has an error - The masterpagefile property should be TemplateFile (case insensitive) If you are used by the web page, Will use the TemplateFile path that uses the default setting due to the TemplateFile property in the form

转载请注明原文地址:https://www.9cbs.com/read-12095.html

New Post(0)