Reputation:
The form has one asp:label and one html input button. On the button click, I want to update the label (e.g. some server side data).
I would like to do this without UpdatePanel or jQuery. I can do a basic ajax call to an .aspx on the button click. What is the best way to update the label with the result? [figure it has to be an asp:label]
Do I need a hidden field which gets loaded with the label's ClientID on Page_Load? Is there an easier way?
thx
Upvotes: 0
Views: 623
Reputation: 15673
Just updated the innerHtml of the label. Emit the ClientID property somewhere to give you a back-reference to the object. IE:
doUpdate()
{
var label = document.getElementById('<%= MyLabel.ClientID %>');
label.innerHTML = getMyAjaxValue();
}
PS: one important thing to note is that this won't effect the page's viewstate, so if you are reading values from the label after postback, you are SOL. In that case, you might want to pair the label up with an ASP:Hidden control to capture the data.
Upvotes: 4