Webform built-in Object Session object, application global object, ViewState

Source: Internet
Author: User

Session

Each computer accesses the server, has the independent Session,key value is identical, the content is different.

1.session is saved on the server.

2.session has no persistence, and the save period is 20 minutes.

Focus: Do not abuse the session, do not use, misuse will cause server overflow, do not cause waste of resources.

Assignment: session["key"] = value;
Value: String a = session["key"];
Clear: session["key"]=null;

Application

application["Key"] is all the user gets the value inside the key is the same, no save cycle, he will always save, usually used as a version number

Assignment value: application["key"]= value;
Value: Application.get ("key");

Command operation for Repeater:

    1. ItemCommand Event--all the controls that can trigger an event in repeater will trigger this event
    2. commandname--Judging what button is clicked, E.commandname
    3. commandargument--the primary key value data passed by the triggering event, which is placed in a single quotation mark E when bound at the face value.
    4. ItemCreated-the event is executed once the HTML code is generated in the item template
    5. ItemDataBound-Item Template performs this event once data is bound

Example:

 <ItemTemplate> <tr class= "Tr_item" style= "<% #Eval (" Blue ")%>" > <td&gt ; <% #Eval ("UserName")%></td> <td><% #Eval ("Password")%></td> &                lt;td><% #Eval ("nickname")%></td> <td><% #Eval ("Sexname")%></td>                <td><% #Eval ("Birthdayn")%></td> <td><% #Eval ("Age")%></td> <td><% #Eval ("Nationname")%></td> <td><asp:button id= "Button1" runat= "Server" text= "remove" commandname= "delete" commandargument= ' <% #Eval ("UserName")%> '/> & Lt;asp:button id= "Button2" runat= "Server" text= "Modify" Commandname= "Xiugai" commandname= "delete" commandargument= ' <%            #Eval ("UserName")%> '/> </td> </tr> </ItemTemplate>

Background code:

if (E.commandname = = "Delete")//delete button        {            new Userda (). Delete (e.commandargument.tostring ());            Repeater1.datasource = new Userda (). Select ();            Repeater1.databind ();        }        if (E.commandname = = "Xiugai")        {            new Userda (). Select (E.commandargument.tostring ());            Repeater1.datasource = new Userda (). Select ();            Repeater1.databind ();        }

Webform built-in Object Session object, application global object, ViewState

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.