Today, while collating the code, I found that half of the previous functions were not implemented. Perfect today, and selfless to share the code to everyone.
Front Code:
1 <!DOCTYPE HTML Public "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/TR/xhtml1/DTD/ Xhtml1-transitional.dtd ">2 3 <HTMLxmlns= "http://www.w3.org/1999/xhtml" >4 <Headrunat= "Server">5 <title>HTML5 Learning</title>6 </Head>7 <Body>8 <formID= "Form1"runat= "Server">9 <Div>Ten One <inputID= "Text1"type= "text"onchange= "Setcookie (' gid_434 ', ' 434 ')"/> A </Div> - </form> - </Body> the </HTML> - <Scripttype= "Text/javascript"> - functionSetcookie (name, value) { - var Days= -; + varExp= NewDate (); - Exp.settime (Exp.gettime ()+ Days* - * - * - * +); + Document.cookie=name+ "=" +Escape (value)+ "; expires=" +exp.togmtstring (); A } at </Script>
Background code:
usingSystem;usingSystem.Linq;usingsystem.web; Public Partial classGetCookies:System.Web.UI.Page {protected voidPage_Load (Objectsender, EventArgs e) { stringErr_msg =string. Empty; if(Request.Cookies.AllKeys.Count () >0&& Request.Cookies.AllKeys.Contains ("gid_434")) { if(request.cookies["gid_434"]. Value = =NULL) {err_msg="cookies:gid_434 temporarily no data"; Response.Write (string. Format ("<script>alert (' {0} ') </script>", err_msg)); } Else{err_msg= request.cookies["gid_434"]. Value.tostring (); Response.Write (string. Format ("<script>alert (' {0} ') </script>", err_msg)); } } Else{err_msg="cookies are empty"; Response.Write (string. Format ("<script>alert (' {0} ') </script>", err_msg)); } } }