Sudipta Bhattacharyya
Sudipta Bhattacharyya

Reputation: 111

cannot set text attribute of asp.net button in jquery

I am having problem here, I can get the 'Text' of asp.net button by using 'val()' in jQuery, but could not set the 'Text' in any way. I have tried 'attr','prop','val()','text()' and 'html()'. Please help.

JavaScript

$("#<%= hiddenButton.ClientID %>").attr('text', 'hello');
var sh = $("#<%= hiddenButton.ClientID %>").val();
alert(sh);

ASPX

<asp:Button ID="hiddenButton" runat="server"  onclick="hiddenButton_Click" Text="NORTH EAST FESTIVAL" />

The alert box still shows "NORTH EAST FESTIVAL".

my html is inside a content placeholder, which is inside a form tag.

Upvotes: 1

Views: 1205

Answers (1)

Milind Anantwar
Milind Anantwar

Reputation: 82231

you need to use .val() to set the value instead of setting the attribute:

$("#<%= hiddenButton.ClientID %>").val('hello');

Upvotes: 1

Related Questions