0

我正在尝试使用以下代码将字符串值传递给 Direct Method。

<html>
 <head runat="server"> 
    <script runat="server">
       protected void btnSubmit_DirectClick(object sender, Ext.Net.DirectEventArgs e)
            {
               string Name = "Lewis Bland";
               string Address = "Las Angels";
          X.Msg.Confirm("Confirmation", "Do you want to submit the Details", new MessageBoxButtonsConfig
           {
            Yes = new MessageBoxButtonConfig
                {
                Handler = "#{DirectMethods}.fnSaveNameAndAdress(" + Name + "," + Address + ")",
                Text = "Yes"
                },
               No = new MessageBoxButtonConfig
                  {
                  Text = "No"
                    }
            }).Show(); 
     }

  [DirectMethod(Namespace = "TestAlias")] 
  public void fnSaveNameAndAdress(string Name, string Address)
   {
        X.Msg.Alert("Conformed", "Name and Address Submitted Successfully").Show();
   } 
  </script>
  </head>
<body>
 <form id="form1" runat="server">
  <ext:ResourceManager runat="server" ID="resource" SourceFormatting="true" />
     <ext:Button ID="btnSubmit" runat="server" Text="Submit" OnDirectClick="btnSubmit_DirectClick" />
 </form>
 </body>
</html>

上面的代码在没有任何参数的情况下工作正常,但是当我传递字符串参数时,它没有触发方法。要触发此方法,我通过添加以下行阅读帖子来使用“别名”概念

 [DirectMethod(Namespace = "TestAlias")] 

并且在 CodeBehind 中,我在类上方添加了以下行。

[DirectMethodProxyID(IDMode = DirectMethodProxyIDMode.Alias, Alias = "TestAlias")]

即使我添加了这些,它确实触发了任何事件。如何克服这种情况。

谢谢你。

4

1 回答 1

0
Yes = new MessageBoxButtonConfig
                {
                Handler = "#{DirectMethods}.fnSaveNameAndAdress(" + Name + "," + Address + ")",
                Text = "Yes"

我猜你的代码处理程序内部应该是这样的,

Handler = "TestAlias.fnSaveNameAndAdress(" + Name + "," + Address + ")",
于 2013-09-15T07:49:54.290 回答