i am creating a dynamic textbox control from the code behind… my question is. how can i attach the javascript code to a dynamic created textbox?
here is the code that creates dynamic Textbox.
TextBox t = new TextBox();
t.ID = "txtDynamic";
t.TextMode = TextBoxMode.MultiLine;
t.Rows = 7;
below is the Javascript….would like to add to the above control created.
$('txtDynamic').limit('140','#charsLeft');
When using ASP.NET WebForms I always try and stay away from referring to IDs in my javascript because the rendered ID may not always be the same as the server side ID.
Use
CssClassto ensure consistency, and a.prefix instead of#prefix in your jquery selector.