1<body >2<form method= "POST" action= "Program.ashx" >3<input type= "hidden" value= "true" name= "IsPostBack"/>4<!--The purpose of the hidden field is to determine if the form is submitted to program.ashx-->5Name: <input type= "text" Name= "Ming" value= "@value"/>6<input type= "Submit" value= "Submission"/>7 @msg8</form>9</body>Ten One A -PublicvoidProcessRequest (HttpContext context) - { theContext. Response.ContentType = "Text/html"; -String FullPath = context. Server.MapPath ("htmlgetelementbyid.html"); -String content =File.readalltext (fullpath); -String msg = ""; +String Ispostback=context. request["IsPostBack"]; -String ming = context. Request["Ming"]; + A if(ispostback== "true") at { -Context. Response.Write ("Submit Entry"); -msg = ming + "Hello"; - } - Else - { inContext. Response.Write ("Direct access"); - } toContent = content. Replace ("@value", Ming); +Content = content. Replace ("@msg", msg); - context. Response.Write (content); the context. Response.Write (Ming); *}
Implement key value self-increment
Public class Increasevalue:ihttphandler { publicvoidProcessRequest (HttpContext context) {context. Response.ContentType= "Text/html"; String IsPostBack=context. request["IsPostBack"]; String number= Context. request["Number"]; if(ispostback== "true") { if(Number = = "@value") Number = "0"; inti =Convert.ToInt32 (number); I++; number=i.tostring (); } Else{ number= "0"; } String Path= Context. Server.MapPath ("increasevalue.html"); String Content=System.IO.File.ReadAllText (path); Content=content. Replace ("@value", number); Context. Response.Write (content); }<body> <form action= "Increasevalue.ashx" > <input type= "hidden" value= "true" name= "IsPostBack"/> <input type= "text" value= "@value" name= "number"/> <input type= "Submit" value= "self-increment"/> </form& Gt;</body>
Asp. NET primary Learning one (Basic statement primer)