Problem description: after submitting a. Net website, the CSS part becomes invalid, such as the DIV position and font size.
Problem solved: The cause is that we used response for all the prompt statements in the past. write ("<SCRIPT> alert (" *** ") </SCRIPT>"), used. write outputs JS scripts.
Alert destroys CSS loading. Solution: Set response. change write ("<SCRIPT> alert (" *** ") </SCRIPT>") to page. registerstartupscript ("Startup", "<SCRIPT> alert (" *** ") </SCRIPT> ").
The following is the standard code on msdn.
<HTML>
<Head>
<Script language = "C #" runat = "server">
Public void page_load (Object sender, eventargs E)
{
If (! This. isstartupscriptregistered ("Startup "))
{
String scriptstring = "<script language = JavaScript> function doclick (){";
Scriptstring + = "showmessage2.innerhtml = '<H4> welcome to Microsoft. NET! </H4> '}";
Scriptstring + = "function page_load () {showmessage1.innerhtml = ";
Scriptstring + = "'<H4> registerstartupscript example </H4>'} <";
Scriptstring + = "/";
Scriptstring + = "script> ";
This. registerstartupscript ("Startup", scriptstring );
}
}
</SCRIPT>
</Head>
<Body topmargin = "20" leftmargin = "10" onLoad = "page_load ()">
<Form ID = "myform" runat = "server">
<Span id = "showmessage1"> </span>
<Br>
<Input type = "button" value = "clickme" onclick = "doclick ()">
<Br>
<Span id = "showmessage2"> </span>
</Form>
</Body>
</Html>
Http://beijing.liebiao.com/wangzhanjianshe/46752756.html