Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/466.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在回调时显式地从javascript函数传递ComponentArt CallBackEventArgs?_Javascript_Asp.net_Callback_Componentart - Fatal编程技术网

如何在回调时显式地从javascript函数传递ComponentArt CallBackEventArgs?

如何在回调时显式地从javascript函数传递ComponentArt CallBackEventArgs?,javascript,asp.net,callback,componentart,Javascript,Asp.net,Callback,Componentart,我有一个ComponentArt回调控件。客户端,我想在下拉列表更改时使用javascript执行回调。在javascript中,我希望显式地传递控件和相关组件art.Web.UI.CallBackEventArgs 下面是我试图在更大范围内实现的基本实现 我应该在javascript中放入什么来显式传递ComponentArt.Web.UI.CallBackEventArg?假设这是可能的,我感兴趣的部分在这里标记为“我放了什么” ascx控件包含: <%@ Control Langua

我有一个ComponentArt回调控件。客户端,我想在下拉列表更改时使用javascript执行回调。在javascript中,我希望显式地传递控件和相关组件art.Web.UI.CallBackEventArgs

下面是我试图在更大范围内实现的基本实现

我应该在javascript中放入什么来显式传递ComponentArt.Web.UI.CallBackEventArg?假设这是可能的,我感兴趣的部分在这里标记为“我放了什么”

ascx控件包含:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="foo.ascx.cs" Inherits="WebPlugins.foo" %>
<%@ Register TagPrefix="ComponentArt" Namespace="ComponentArt.Web.UI" Assembly="ComponentArt.Web.UI" %>

<script language="javascript" type="text/javascript">
    function changeDDL(sender) {
        alert("This alert pops up. No problems here.");
        fooClbk.Callback(sender, WHAT_DO_I_PUT_HERE );
    }
</script>

<ComponentArt:CallBack id="fooClbk" runat="server" OnCallback="fooClbk_Callback">
    <Content>
        <asp:Label ID="lblmyDDL" AssociatedControlID="myDDL" runat="server" Text="Choose an option: "></asp:Label>
        <br />
        <asp:DropDownList ID="myDDL" runat="server">
            <asp:ListItem Value="DEFAULT" Text="The Default Value"></asp:ListItem>
            <asp:ListItem Value="ONE" Text="First!"></asp:ListItem>
            <asp:ListItem Value="TWO" Text="Runner up"></asp:ListItem>
        </asp:DropDownList>
    </Content>
    <LoadingPanelClientTemplate>
        <p>Refreshing Rate Information...</p>
    </LoadingPanelClientTemplate>
</ComponentArt:CallBack>
//Some includes...

namespace WebPlugins
{
    public partial class foo : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            initializeDDLEvt();
            //Initialize some other stuff...
        }

        private void initializeDDLEvt()
        {
            /* Register client events for DDL */
            myDDL.Attributes.Add("onChange", "changeDDL(this);");
        }

        protected void fooClbk_Callback(object sender, ComponentArt.Web.UI.CallBackEventArgs e)
        {
            //Render some new HTML using the ComponentArt.Web.UI.CallBackEventArgs
        }
    }
}

编辑:我对这里发生的事情的基本理解是错误的。我已经在下面的评论中提供了一些我出错的细节。感谢@jalpesh提供componentart论坛链接。这为我指明了我需要走的方向。

这个问题的快速答案是:不能完全按照问题的措辞来做

更详细地说:

假设javascript函数在回调时显式传递发送方和事件参数。事实并非如此。相反,javascript函数传递一些绑定到事件参数中的参数

发送方(在本例中为dropdownlist控件)和CallBackEventArgs隐式传递给fooClbk_回调方法。我认为这在一定程度上是一种误解

基本上,这是:

function changeDDL(sender) {
    alert("This alert pops up. No problems here.");
    fooClbk.Callback(sender, WHAT_DO_I_PUT_HERE );
}
实际上应该是这样的:

function changeDDL(aControl) {
    alert("This alert pops up. No problems here.");
    fooClbk.Callback(aControl.options[aControl.selectedIndex].value); // Or whatever other params
}
protected void fooClbk_Callback(object sender, ComponentArt.Web.UI.CallBackEventArgs e)
{
    //Do Some stuff
    string myVal = e.Parameters[0];
    // Do something with the chosen myVal.
}
从javascript函数传入的参数可以在回调方法中访问,如下所示:

function changeDDL(aControl) {
    alert("This alert pops up. No problems here.");
    fooClbk.Callback(aControl.options[aControl.selectedIndex].value); // Or whatever other params
}
protected void fooClbk_Callback(object sender, ComponentArt.Web.UI.CallBackEventArgs e)
{
    //Do Some stuff
    string myVal = e.Parameters[0];
    // Do something with the chosen myVal.
}

我想我不明白你的问题。你想用回调方法做什么?@Sergey我想做一些我做不到的事情。。。我会跟进一个详细的评论。