1

我想在回调中获取电子邮件(来自 txtEmail 字段的文本值)

我有文本字段:

  <asp:TextBox MaxLength="50" runat="server" ID="txtEmail" ClientIDMode="Static" onblur="SendRequest()"></asp:TextBox>

我的 javascript 处理程序:

 <script type="text/javascript">
      function SendRequest(arg) {
           window.UseCallback(arg);
      }
 </script>

和服务器事件处理程序

 protected void Page_Init(object sender, EventArgs e)
 {
    string cbReference = Page.ClientScript.GetCallbackEventReference(this, "arg", "GetEmailFromServer", "context");
    string cbScript = "function UseCallback(arg, context){" + cbReference + ";}";
    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "UseCallback", cbScript, true);
 }

 public void RaiseCallbackEvent(string eventArg)
 {
     var result = Controller.CheckEmail(eventArg);      // eventArg == undefined
 }

如何将 eventArg 设置为 txtEmail.Text ?

4

1 回答 1

0

更改此行并检查

 string cbScript = "function UseCallback(arg){" + cbReference + ";}"; 

改变这个

<script type="text/javascript">        
       function SendRequest(arg) 
        {
             window.UseCallback(arg,"");
        }   
</script>  
于 2012-08-28T10:07:41.533 回答