I’m very new in .net c#, just a question here to about the following code. I have wrote a code to display a text box on the screen as below:
<asp:TextBox ID="sUnit" runat="server" MaxLength="12" Width="3em" />
But somehow I failed to using jqueryto assign a value into this textbox:
$('#sUnit').val('test');
Surprisingly when I view the source code, and it show me the ID for the text box is like below:
<input name="ctl00$cplh$sUnit" type="text" maxlength="12" id="ctl00_cplh_sUnit" style="width:3em;" />
Does anyone know how can I get the textbox ID so that I can assigned the value into the textbox?
Hope my question is not sound stupid.
If you are using ASP.NET 4.0, set the
ClientIDModetostatic.For older versions, use
$('#<%= sUnit.ClientID %>')