Anupam Roy
Anupam Roy

Reputation: 1674

error in getting asp server element in javascript

I am having problem to get asp server element data.
Here is my textbox for usercode.
and the script where i want to get its valu. but its not working.
please help me in this.

thnx in advance.

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<div>
<asp:TextBox ID="txtUserCode" runat="server" Width="78%" Height="35%"></asp:TextBox>
</div>
</asp:Content>

<script type="text/javascript">
$(document).ready(function ()
{
  $("input[type='text']").change(function ()
      {            
          var textBox = document.getElementById('<%= txtUserCode.ClientID %>');
          alert(textBox);

     });
 });
</script>

Upvotes: 0

Views: 171

Answers (1)

IUnknown
IUnknown

Reputation: 22448

Use alert(textBox.value); instead of alert(textBox)

Upvotes: 3

Related Questions