求助:ASP.NET中页面重绘函数问题,
上课时简单的加法计算器,我用的是.NET4.0以下是ashx.cs文件:using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace WebApplication3
{
/// <summary>
/// Handler1 的摘要说明
/// </summary>
public class Handler1 : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
string num1 = context.Request["text1"];
string num2 = context.Request["text2"];
string num3 = (Convert.ToInt32(num1) + Convert.ToInt32(num2)).ToString();
string address = context.Request.MapPath("HTMLPage1.htm");//得到路径
string str1 = (address);//本来想重绘页面的,但读出来的是txt的源文件代码,为什么老师讲的时候用VS2008操作可以,我用VS2010不可以?
str1 = str1.Replace("#value1",num1);
str1 = str1.Replace("#value2", num2);
str1 = str1.Replace("#value3", num3);
context.Response.Write(str1);
}
public bool IsReusable
{
get
{
return false;
}
}
}
}
以下是HTML页面文件:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www.
<head>
<title></title>
</head>
<body style="height: 56px">
<form action="Handler1.ashx">
<input type="text" value="#value1" name="text1" />+<input type="text" value="#value2" name="text2"/>
<input type="submit" value="=" /><input type="text" name="text3" value="#value3"/>
</form>
</body>
</html>