While I am trying to get the value of textbox with .val(), Its always showing ‘undefined’.
Below is the code i am using. Please help me out friends.
<asp:TextBox runat="server" ID="txtComment" Width="650" />
<asp:Button runat="server" ID="btnSubmitComment" Text="Submit" />
$(document).ready(function () {
$('input[id$=btnSubmitComment]').click(function () {
var comment = $("#txtComment").val();
alert(comment);
});
One standard way on asp.net is to get the rendered id and use it on javascript as:
(from the moment you go with ID, and not use some other way to select the controls, like the css, the type etc.