c# - Change Text of server Control in static Web Method -
i using web method ajax call, want change text of asp.net label control after ajax call. changing text on success of ajax call,but after post not getting updated value, changing on client side. want change text reflect on post well. how can change text of label in webmethod? below code
[system.web.services.webmethod()] public static string removeval() { //do work //return updated value //i want change text here } jquery.ajax({ type: "post", url: 'mypage.aspx/removeval', contenttype: "application/json; charset=utf-8", datatype: "json", success: function (data) { var emaillbl = getclientid("lblemail").attr("id"); $("#" + emaillbl).html(data); } }); <asp:label id="lblemail" runat="server" cssclass="labelclass"></asp:label> function getclientid(id, context) { var el = $("#" + id, context); if (el.length < 1) el = $("[id$=_" + id + "]", context); return el; }
ajax call update control text in client side only. if want change label's text after post , bind changed value again control while page posts back. can call function binds changed value label in postback event or in page load wherever seems fit.
Comments
Post a Comment