开发者

Jquery Masterpage Can not Change the text for a textbox from client side

Ok this one is one of those that has had me bangin my head against the wall for acouple of hours. It seems very simple, I am using a Masterpage, Telerik controls and telerik RadScriptblock and Jquery. I am trying to change the text of an asp.net textbox in the grid edit form from client side code but it JUST WILL not WORK! I have tried the followi开发者_如何学Pythonng with no luck.

 Text box: 

 <asp:TextBox  ID="txtNewProduct" runat="server"/>

 // JQuery inside RadScriptBlock
 //Have tried all these but dont work

// $('#txtNewProduct').text('New Product');
//  $('#txtNewProduct').attr('text', 'New Product');
//  $('#txtNewProduct').val('New Product');

//This one gets me the object but it CANT seem to set the text have been trying 
//for hours

//var txtnew = $('[id$=txtProduct]');
//txtnew.text = "New Product";  //This shows the value "New Product" in clienst side 
//but does not change the textbox's text

If someone can point out how to do this simple task you might save me and some other poor soul some therapy :) thank you in advance.


The id is most likely changed if you are using a master page, check the source code that is generated.


As Paul Creasey said, check the generated source and then ensure your jQuery library file(s) successfully loaded...if loaded, then use something like Firebug (in Firefox) to test the jQuery. $('#txtNewProduct').val('New Product') should work.


Wow that was frustrating I hope it helps someone else out as well I was able to change the textbox's text using

$('[id$=txtNewProduct]').val('New Product');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜