ASP. NET Status view test-1

Source: Internet
Author: User

After Asp.net is submitted, it is still maintained. I have been very vague. I did a test and found that the client script is not maintained, it seems that, unless it is a server control and something changed on the server side, it is stored in the view State for maintenance, and others, it does not matter, you refresh or submit, it is all the same!

UpperCode:

 <%  @ Page Language  =  "  C #  "  Autoeventwireup  =  "  True  "  Codebehind  = "  Webform1.aspx. CS  "  Inherits  =  "  Webapplication1.webform1  "     %>  

<! Doctype HTML public " -// W3C // dtd xhtml 1.0 transitional // en " " Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd " >

< HTML xmlns = " Http://www.w3.org/1999/xhtml " >
< Head runat = " Server " >
< Title > </ Title >
< Script Type = " Text/JavaScript " >
Function outbtn_click ()
{
Document. getelementbyid (
" Outdiv " ). Innerhtml = " I got rid of you !! " ;
Document. getelementbyid (
" Indiv " ). Innerhtml = " I got rid of you !! " ;
Document. getelementbyid (
" Label1 " ). Innerhtml = " I got rid of you !! " ;
}
</ Script >
</ Head >
< Body >
< Div ID = " Outdiv " > I am outside </ Div >
< Input type = " Button " Value = " Outbn " Onclick = " Outbtn_click () " />
< Form ID = " Form1 " Runat = " Server " >
< Div ID = " Indiv " >
Haha, my div is in form. Test it and see that ASP will automatically maintain the status for me.
</ Div >

< ASP: Label ID = " Label1 " Runat = " Server " Text = " I'm a server-side control. Come on, I'm not afraid! " > </ ASP: Label >
< BR />
< ASP: button text = " Button " Runat = " Server " />
</ Form >
</ Body >
</ Html >

After pressing the outbn button, you can use the client js to modify the content of the control to be tested, as shown below:

When you press the button, all the content is changed back, whether outside the form, in the form, or even the server control. Because the content changed by the client is not in the Status view, therefore, it cannot be saved after submission.

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.