首页 > 代码库 > ASP.Net初级学习一(基本语句入门)
ASP.Net初级学习一(基本语句入门)
1 <body > 2 <form method="post" action="program.ashx"> 3 <input type="hidden"value="http://www.mamicode.com/true"name="ispostback" /> 4 <!--隐藏字段的作用是判断是否是提交表单进入program.ashx--> 5 姓名:<input type="text" name="ming"value="http://www.mamicode.com/@value"/> 6 <input type="submit" value="http://www.mamicode.com/提交" /> 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="http://www.mamicode.com/true"name="ispostback" /> <input type="text"value="http://www.mamicode.com/@value"name="number"/> <input type="submit"value="http://www.mamicode.com/自增" /> </form></body>
ASP.Net初级学习一(基本语句入门)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。