Asp. NET primary Learning one (Basic statement primer)

Source: Internet
Author: User
Tags httpcontext ming

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)

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.