1. directly use response. when the write () method is used to output alert or other JS Code , some page styles are affected
Because response. before the write method outputs the <SCRIPT> label to the <doctype> label, the <doctype> label is ignored, as a result, the browser interprets the page as a bunch of tags rather than a valid HTML document. The page rendering mode is changed to the quirks mode) instead of the standard compatible mode (Standards Compliance mode), this affects the interpretation of HTML and CSS, because the browser attempts to imitate a comparative version of it, it will produce a lot of weird and wrong. In addition, he will use different default styles for the elements, which leads to final style problems.
The following is an important sentence:<Doctype> anything before the label will cause the <doctype> label to be ignored.
Method 1: Replace the response. Write () statement with this
Page. registerstartupscript ("servicemanhistorybuttonclick", "<SCRIPT> window. Open ('equipmenthistory. aspx? Eid = "+ servicemandropdownlist. selectedvalue +" '); </SCRIPT> ");
This method is used to issue a client script block in the page response. The previous parameter is the unique name of the script in the page (you can start it without repeating it), and the other is the script content.
This method should be officially recommended by Microsoft.
Method 2: originalProgramThe response. Write () Statement
Response. Write ("<SCRIPT> document. Location = Document. Location; </SCRIPT> ");
2,Microsoft Ajax technology is used in ASP. NET to export the Excel file in updatepanel. Http://topic.csdn.net/u/20080412/14/502aaafd-609c-4063-bc5f-ee91cc9140a2.html Solution: <Asp: scriptmanager id = "scriptmanager1" runat = "server" enablescriptglobalization = "true" enablescriptlocalization = "true"> </ASP: scriptmanager>
<Asp: updatepanel id = "updatepanel1" runat = "server">
<Contenttemplate>
<Br/>
Your own HTML code...
<Asp: gridview id = "gridview1" runat = "server">
</ASP: gridview>
<Asp: linkbutton id = "lbtnexport2excel" runat = "server" onclick = "lbtnexport2excel_click"> export Excel </ASP: linkbutton>
</Contenttemplate>
<Triggers>
<Asp: postbacktrigger controlid = "lbtnexport2excel"/>
</Triggers>
</ASP: updatepanel>
3. Rewrite verifyrenderinginserverform method http://blog.csdn.net/JeromeLvye/article/details/5250701 if an exception occurs, code scheduling directly enters the Catch Block, the custom output code will not execute context. response. write (SW. tostring (), and the system outputs the entire page. All the unnecessary controls are exported. Publish via wiz