asp.net 后台计算器

THMLpage.htm   请求页

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
</head>
<body>
<form action ="Handler.ashx">
<input type="hidden" name="ispostback" value="true" />
<input type="text" value="@value1" name="number1" /><input type="text" value="@value2" name="number2" /><input type="submit" value="=" />
<input type="text"  value="@value3"/>
</form>
</body>
</html>

Handler.ashx 响应页


<%@ WebHandlerLanguage="C#"Class="Handler"%>

 

using System;

using System.Web;

 

public class Handler : IHttpHandler{

   

    public void ProcessRequest (HttpContextcontext) {

        context.Response.ContentType = "text/plain";

        stringispostback = context.Request.QueryString["ispostback"];

        stringnumber1 = context.Request.QueryString["number1"];

        stringnumber2 = context.Request.QueryString["number2"];

       

        stringvalue3 = "";

 

        if(ispostback == "true")

        {

            value3 = (Convert.ToInt32(number1)+ Convert.ToInt32(number2)).ToString();

        }

 

        stringfullpath = context.Server.MapPath("HTMLPage.htm");

        stringcon = System.IO.File.ReadAllText(fullpath);

        con = con.Replace("@value1", number1);

        con = con.Replace("@value2", number2);

        con = con.Replace("@value3", value3);

        context.Response.Write(con);

       

           

    }

 

    public bool IsReusable {

        get {

            returnfalse;

        }

    }

 

}

 



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值