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

1如何判断是提交进入还是直接进入

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

3占位符的控制,使本本框内容在提交以后保持

ASP中的代码:

<formaction="Once.ashx"method="get">

<inputtype="hidden"name="isNullText"value="true"/>
<inputtype="text"name="price"value="0"/>
<inputtype="submit"value="提交"/>

</form>


ashx输入html文件中内容:

publicclassOnce:IHttpHandler{

publicvoidProcessRequest(HttpContextcontext){
context.Response.ContentType="textml";

stringnum=context.Request["price"];//获得文本框的value值
stringisNullText=context.Request["isNullText"];//得到表单的value值。"true"

if(isNullText=="true")//如果相等是提交进来的并将将文本框里面的值加1,否则将文本里面的值负值为0
{
context.Response.Write("提交进入!");
num=(int.Parse(num)+1).ToString();
}
else
{
context.Response.Write("直接进入!");
num="0";
}

stringfullPath=context.Server.MapPath("index.htm");//获得html的路径将它给一个变量
stringhtmlContext=System.IO.File.ReadAllText(fullPath);//将这个路径负值给一个变量
htmlContext=htmlContext.Replace("0",num);//将文本框原有的值替换为改变后的数
context.Response.Write(htmlContext);//将整个html输出

context.Response.Write("HelloWorld");

}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值