getting the value of textbox of Grid
Now , I am using ASP.net with C# . I ha开发者_如何学JAVAve a Grid and there are two text box controls in it. How should I do to get the value of these two text box controls from JavaScript.
Regards
You can get the value of text box in grid view through java script as follows:
Just add a call to a javascript function on onblur or on keypress or any other event you want, of the textbox control you want to get the value of, like following:
<ItemTemplate>
<asp:TextBox ID="TextBox1" OnBlur = "javascript:return DefaultValue(this);"
runat="server" Text='1'>
</asp:TextBox>
</ItemTemplate>
Now in script tag creat a function like this:
function DefaultValue(name) {
var value = document.getElementById(Name.id).value;
alert(value);
}
Hope This Helps.
this example will get the control that has an id of "theIDOfMyTextBox" and then place the text into the variable text
<script type="text/javascript">
var textBox = document.getElementById("theIDOfMyTextBox");
var text = textBox.value;
</script>
WC3 Schools has an online javascript editor that you can use, as does google
精彩评论