Built-in objects:
1. Request-Gets the requested object
Usage: Receive pass-through value
protected void Page_Load (object sender, EventArgs e) { = request["ABC"]; }
2. Response-Corresponding Request object
Usage:(Lee brainstorming Lxc)
1. Execute code
// Click the button to execute the code void Button1_Click (object sender, EventArgs e) { Response.Write ("<script> Alert (' Hello 2017! ');</script>"); }
2. Print text at the top of the page
// Click the button to print the text void Button1_Click (object sender, EventArgs e) { Response.Write (" Today is the first day of 2017! "); }
3, jump page and pass value (Li brainstorming lxc)
// Click on the button to jump page void Button1_Click (object sender, EventArgs e) { Response.Redirect (" default.aspx?abc= Hello 2017! "); }
3, Session-Server global variable group-each user access is private, independent of each other
Storage location: Service side
Life cycle: 20 minutes
Usage: Pass Value
Web1 Assignment WEB2 Value
// button click event void Button1_Click (object sender, EventArgs e) { string s = TextBox1.Text; session["un"] = s; }
if (session["un"null) { = session["un" ]. ToString (); }
4, Cookie-Client global variable group-each user access is private, independent of each other
Storage location: Client (Lee brainstorming LXC)
Life cycle: Session cookie 20-minute persistent Cookie Unlimited
Cookie Life cycle Settings:
//button click event voidButton1_Click (Objectsender, EventArgs e) { strings =TextBox1.Text; if(s = ="ADIMN"&& TextBox2.Text = ="1234") {response.cookies["un"]. Value =s; //set [Persistent cookie] time when selected if(checkbox1.checked) {response.cookies["un"]. Expires = DateTime.Now.AddDays (3); } Response.Redirect ("default2.aspx"); } }
Usage: Web1 Assignment web2 value
// button click event void button1_click (object sender, EventArgs e) { string s = TextBox1.Text; response.cookies[ " un "]. Value = S; }
if (request.cookies["un"]!=null) { = request.cookies["un"]. Value; }
5, application-Global public variable group-all Access users are the same variable that is accessed, such as information presented to all users
Available for server caching
Storage location: Service side (Lee brainstorming Lxc)
usage: Pass Value
Web1 Assignment WEB2 Value
// button click event void button1_click (object sender, EventArgs e) { string s = TextBox1.Text; application[ " un " ] = S; }
if (application["un"null) { = application["un "]. ToString (); }
6, ViewState-because of the non-state of the HTML, it will not know what your previous page is state, ViewState function is to record the status of the previous page, similar to "case", record information
c#-webform-★ Introduction to Built-in objects ★request-Get Request object, response corresponding Request object, session global variable (private), cookie global variable (private), application global public variable, ViewState