Here i have passed the text control to the java script function but i just want to pass the value of the text box to the java script function instead on onkeyup.
function Changed(textControl) {
var _txtEmpName = document.getElementById('<%=txtEmpName.ClientID%>');
var _EnteredString = _txtEmpName.value;
<asp:TextBox
ID="txtEmpName" runat="server" onkeyup="javascript: Changed( this );"></asp:TextBox>
Here i have passed the text control to the java script function but i just want to pass the value of the text box to the java script function instead on onkeyup.
function Changed(textControl) {
var _txtEmpName = document.getElementById('<%=txtEmpName.ClientID%>');
var _EnteredString = _txtEmpName.value;
<asp:TextBox
ID="txtEmpName" runat="server" onkeyup="javascript: Changed( this );"></asp:TextBox>
Share
Improve this question
edited Aug 24, 2012 at 15:21
John Conde
220k99 gold badges463 silver badges502 bronze badges
asked Aug 24, 2012 at 15:19
user1588242user1588242
352 silver badges10 bronze badges
2
- document.getElementById('<%=txtEmpName.ClientID%>').value ? – Joe Commented Aug 24, 2012 at 15:30
- See this url it's working nice for me... [How to call javascript function on keyup event for asp:TextBox][1] [1]: stackoverflow./questions/5607313/… – csharpbd Commented Jul 14, 2013 at 18:06
3 Answers
Reset to default 3If you want to pass the value instead, simply do:
<asp:TextBox ID="txtEmpName" runat="server"
onkeyup="javascript: Changed( this.value );"></asp:TextBox>
Not sure if I understand, but if you want to pass the value you should use this.value
instead of just this
<asp:TextBox ID="txtEmpName" runat="server" onkeyup="Changed(this.value)">
</asp:TextBox>
Maybe use onblur instead of onkeyup? You will be calling that function with every keystroke, is that something you really want to do?