<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:TextBox ID="txt" runat="server">
</asp:TextBox>
<asp:Button ID="btn" runat="server" Text="提交"
OnClientClick="document.getElementById('ifr').src='Handler.ashx';return false;" />
<iframe id="ifr"></iframe>
<script type="text/javascript">
var callBack = function (val) {
document.getElementById('<%=txt.ClientID %>').value += val;
}
</script>
</form>
</body>
</html>
Handler.ashx.cs
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
for (int i = 0; i < 20; i++)
{
context.Response.Write("<script type='text/javascript'>parent.callBack(" +
i.ToString() + ");</script>");
context.Response.Flush();
System.Threading.Thread.Sleep(1000);
}
}