Goodspeed

导航

asp.net 2.0 中无刷新机制

 

<%@ Page Language="C#" %>
<%@ Implements Interface="System.Web.UI.ICallbackEventHandler" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<script runat="server">
    
protected void Page_Load(object sender, EventArgs e)
    
{
        
string callback = this.ClientScript.GetCallbackEventReference(this"this.value""ProcessReverse"null);
        
this.TextBox1.Attributes.Add("onchange", callback);
    }


    
string ICallbackEventHandler.RaiseCallbackEvent(string eventArgument)
    
{
        
char [] chars = eventArgument.ToCharArray();
        Array.Reverse(chars);
        
return new string(chars);
    }

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    
<title>Untitled Page</title>
</head>
<body>
    
<form id="form1" runat="server">
    
<div>
    
<asp:TextBox ID="TextBox1" Runat="server"></asp:TextBox>
    
</div>
        
    
</form>
</body>
</html>
<script>
function ProcessReverse(result,context)
{
    alert(result)
    document.all.TextBox1.value 
= result;
}

</script>

posted on 2004-08-23 09:27  Goodspeed  阅读(1588)  评论(0编辑  收藏  举报