. Net website construction page failure after submission

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.