您的位置:首页 > Web前端 > HTML

在ashx文件中输出html中的文本框和按钮,并且当单击按钮时,输出文本框中的文字到网页上,同时文本框中的内容对峙不变。

2012-11-20 09:13 531 查看
1如何断定是提交进入还是直接进入

2应用模板机制在ashx输入html文件中内容

3占位符的把握,使本本框内容在提交今后对峙

ASP中的代码:

<form action="Once.ashx" method="get">

< input type="hidden" name="isNullText" value="true" />

< input type="text" name="price" value="0" />

< input type="submit" value="提交" />

< /form>

ashx输入html文件中内容:

public class Once : IHttpHandler {

public void ProcessRequest (HttpContext context) {

context.Response.ContentType = "textml";

string num=context.Request["price"]; //获得文本框的value&#20540;

string isNullText = context.Request["isNullText"]; //获得表单的value&#20540;。"true"

if (isNullText == "true") //若是相等是提交进来的并将将文本框里面的&#20540;加1,不然将文本里面的&#20540;负&#20540;为0

{

context.Response.Write("提交进入!");

num=(int.Parse(num)&#43;1).ToString();

}

else

{

context.Response.Write("直接进入!");

num="0";

}

string fullPath = context.Server.MapPath("index.htm"); //获得html的路径将它给一个变量

string htmlContext = System.IO.File.ReadAllText(fullPath); //将这个路径负&#20540;给一个变量

htmlContext = htmlContext.Replace("0",num); //将文本框原有的&#20540;调换为改变后的数

context.Response.Write(htmlContext); //将全部html输出

context.Response.Write("Hello World");

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐