I have a Nested Gridview having textbox & Button
column. How to display value of textbox
in alert when Button Click
by using jquer
You can try:
<asp:TemplateField>
<ItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" />
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="showText(this); return false;" />
</ItemTemplate>
</asp:TemplateField>
with the following showText
function, which looks for a text box in the same table cell as the button that was clicked:
function showText(btn) {
alert($(btn).closest('td').find('input[type=text]').val());
}
UPDATE
According to your other question, the text box and the button could be inside of a div container. If that is the case, the function showText
should be:
function showText(btn) {
alert($(btn).closest('div').find('input[type=text]').val());
}
In your web.config
add clientIDMode
like this:
<pages clientIDMode="Static"></pages>
Then:
$(function() {
$("#Button1").click(function(e) {
e.preventDefault();
alert($("#TextBox1").val());
});
});