<!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="homework.ashx">
<input type="hidden" name="ispostback" value="true" />
<input type="text" name="Text" value="@value" />
<input type="submit" value="增加" />
</form>
</body>
</html>
<%@ WebHandler Language="C#" Class="homework" %>
using System;
using System.Web;
public class homework : IHttpHandler {
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/html";
string ispostback = context.Request["ispostback"];
string Text = context.Request["Text"];
if (ispostback == "true")
{
int i = Convert.ToInt32(Text);
i++;
Text = i.ToString();
}
else
{
Text = "0";
}
string fullpath=context.Server.MapPath("homework.htm");
string content = System.IO.File.ReadAllText(fullpath);
content = content.Replace("@value", Text);
context.Response.Write(content);
//context.Response.Write("Hello World");
}
public bool IsReusable {
get {
return false;
}
}
}