ASP.Net初級學習一(基本語句入門)

來源:互聯網
上載者:User

標籤:style   blog   http   io   color   os   sp   for   on   

 1 <body > 2     <form method="post" action="program.ashx"> 3         <input type="hidden"value="true"name="ispostback" /> 4         <!--隱藏欄位的作用是判斷是否是提交表單進入program.ashx--> 5         姓名:<input type="text" name="ming"value="@value"/> 6         <input type="submit" value="提交" /> 7         @msg 8     </form> 9 </body>10 </html>11 12 13 public void ProcessRequest(HttpContext context)14         {15             context.Response.ContentType = "text/html";            16             string fullpath = context.Server.MapPath("HtmlGetElementByid.html");17             string content = File.ReadAllText(fullpath);18             string msg = "";19             string ispostback=context.Request["ispostback"];20             string ming = context.Request["ming"];21             22             if (ispostback=="true")23             {24                 context.Response.Write("提交進入");25                 msg = ming + "你好";26             }27             else28             {29                 context.Response.Write("直接進入"); 30             }31             content = content.Replace("@value",ming);32             content = content.Replace("@msg",msg);33             context.Response.Write(content);34             context.Response.Write(ming);35         }

 實現按索引值自增

 public class IncreaseValue : IHttpHandler    {        public void ProcessRequest(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";                int i = 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="自增" />    </form></body>

 

ASP.Net初級學習一(基本語句入門)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.