jackparsana 0 Junior Poster in Training

hi,

I m working on vs 2010. asp.net.

i have problem with apply class using jquery. there is one textbox. i use class by this way its perfectly work.

but when textbox multilink property is true. then problem is raise.


pls help me to use this...

thanks in advance.

jack

Dani AI

Generated

: A multiline ASP.NET TextBox is rendered as a <textarea> on the client, so jQuery selectors that target input[type=text] (or the jQuery :text pseudo) will not match it. Also remember ASP.NET naming containers can change the rendered id, so selecting by a literal id can fail unless you use the control's ClientID or set ClientIDMode="Static".

A couple of practical fixes:

$(function(){
  // select by the server control's client id
  $("#<%= TextBox1.ClientID %>").addClass("myJqClass");
});
$(function(){
  // select both text inputs and textareas
  $("input[type=text], textarea").addClass("myJqClass");
});

You can also set the server-side CssClass="myJqClass" on the TextBox so the class is emitted at render time.

If your page uses UpdatePanel/partial postbacks, classes added with jQuery may be lost after an async update. Reapply them on the endRequest event:

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(function(){
  $("#<%= TextBox1.ClientID %>").addClass("myJqClass");
});

Notes and cautions: CSS rules that target only input elements will not style a textarea, so adjust selectors if you rely on CSS. The jQuery :text selector is for input[type=text] only; see the jQuery docs for details. For how ASP.NET renders the TextBox control and ClientID behavior, see the TextBox documentation.

jQuery :text selector
TextBox control (ASP.NET) documentation

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.