Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/390.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函数中获取列表框项引用_Javascript_Asp.net_Cart - Fatal编程技术网

如何在javascript函数中获取列表框项引用

如何在javascript函数中获取列表框项引用,javascript,asp.net,cart,Javascript,Asp.net,Cart,我在webform.aspx页面上有Listview控件,定义如下 <asp:ListView runat="server" ID="dispalyProducts"> <LayoutTemplate> <table runat="server" id="table1"> <tr runat="server" id="itemPlaceholder">

我在webform.aspx页面上有Listview控件,定义如下

<asp:ListView runat="server" ID="dispalyProducts">
            <LayoutTemplate>
                <table runat="server" id="table1">
                    <tr runat="server" id="itemPlaceholder">
                    </tr>
                </table>
            </LayoutTemplate>
            <ItemTemplate>
                <tr id="Tr1" runat="server">
                    <td id="Td1" runat="server">
                        <%-- Data-bound content. --%>
                        <asp:Label runat="server" Text='<%#Eval("ProductName") %>' />
<br/>
                        <asp:TextBox runat="server" />
                        <br/>
                        <asp:Label runat="server" Text='<%#Eval("ProductID") %>' />
                        <br/>
                        <asp:Button runat="server" Text="Add TO cart" OnClientClick="AddToCart('<%#Eval("ProductID") %>');return false;"/>
                    </td>
                </tr>
            </ItemTemplate>
        </asp:ListView>




当程序运行时,它会创建一个产品ID、名称和按钮的列表

我想将此按钮用作“添加到购物车”功能。所以,当用户单击按钮时,我想用productID和textbox值(作为项目id和数量)调用一个javascript函数

如何将这些值传递给listview中的javascript函数。


<asp:Button ... OnClientClick='AddToCart(\"<%#Eval("ProductID") %>\", \"<%#Eval("ProductName") %>\");return false;'/>

您可以将值作为参数传递给js函数。

它会给我类似于。。。。回发或回调参数无效。在配置或页面中使用启用了事件验证。请提供一些其他信息。您如何向服务器发出请求?如何在服务器端处理请求?在回发/回调之后,服务器端会触发什么事件?