[英]How to get list box item reference in javascript function
I have Listview control on webform.aspx page with below defination... 我在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>
Whent he program runs, it creates a list of product ID, name and a button. 程序运行时,它将创建产品ID,名称和按钮的列表。
I want to use this button as "add to cart" functionality. 我想将此按钮用作“添加到购物车”功能。 so when a user clicks on button, i want to call a javascript function with productID, and textbox value (as item id and quantity). 因此,当用户单击按钮时,我想使用productID和文本框值(作为项目ID和数量)调用JavaScript函数。
How can I pass these values to javascript function in listview. 如何将这些值传递给ListView中的javascript函数。
<asp:Button ... OnClientClick='AddToCart(\"<%#Eval("ProductID") %>\", \"<%#Eval("ProductName") %>\");return false;'/>
您可以将值作为参数传递给js函数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.