asp.net - Using jQuery val with AjaxToolKit's TextBoxWatermarkExtender with IE -
i know, know, "don't use ajaxtoolkit"... assume i'm stuck it.
if have following:
<asp:textbox runat="server" id="textbox" /> <asp:textboxwatermarkextender runat="server targetcontrolid="textbox" watermarktext="text" />
and
var textboxselector = $(#'<%= textbox.clientid %>');
then not work (i.e. changes watermark text not desired text)
textboxselector.val('example text');
however found in chrome:
textboxselector.focus(); textboxselector.val('example text');
but not in internet explorer.
any ideas how implement this?
you need set , use behaviorid of watermark extender itself.
<asp:textbox runat="server" id="textbox" /> <asp:textboxwatermarkextender runat="server targetcontrolid="textbox" behaviorid="textboxwatermark" watermarktext="text" />
then use $find()
access object , set_text()
var textboxwatermark = $find("textboxwatermark"); textboxwatermark.set_text('example text');
if $find()
returning null, may have wait until page loaded. not using jquery, using toolkit
sys.application.add_load(myfunction); function myfunction() { var textboxwatermark = $find("textboxwatermark"); textboxwatermark.set_text('example text'); }
Comments
Post a Comment