How to call webmethor using jquery.http://forums.asp.net/t/1805641.aspx/1?How+to+call+webmethor+using+jquery+Tue, 22 May 2012 05:27:31 -040018056414989173http://forums.asp.net/p/1805641/4989173.aspx/1?How+to+call+webmethor+using+jquery+How to call webmethor using jquery. <p>Hello.</p> <pre class="prettyprint">$('#txtMbUser').click(function () { var username = $('#txtMbUser').val(); $.ajax({ type: &quot;POST&quot;, url: &quot;FormMbRegister.ascx/Usercheck&quot;, data: &quot;username: '&quot; &#43; username &#43; &quot;'&quot;, contentType: &quot;application/json; charset=utf-8&quot;, dataType: &quot;json&quot;, success: function (msg) { alert(msg); }, Error: function(){ alert('loi'); } }); });</pre> <pre class="prettyprint">#region [Check User, Email exits] [WebMethod] public static string Usercheck(string username) { return "Called"; } #endregion</pre> <p><br> <br> </p> <p>It is do not work.</p> 2012-05-21T05:03:40-04:004989221http://forums.asp.net/p/1805641/4989221.aspx/1?Re+How+to+call+webmethor+using+jquery+Re: How to call webmethor using jquery. <p>With Reference to this post ,</p> <p>http://forums.asp.net/t/1795796.aspx/1</p> <p>i say that</p> <p>&quot;There is a limitation. You can not call a webmethod in a user control from jQuery/JavaScript. This is a framework restriction. You can change your design to fit your requirment. May be you can shift the pagemethod to aspx page or some web service.&quot;</p> <p></p> 2012-05-21T05:30:48-04:004991111http://forums.asp.net/p/1805641/4991111.aspx/1?Re+How+to+call+webmethor+using+jquery+Re: How to call webmethor using jquery. <p>Refer this</p> <p><a href="http://encosia.com/using-jquery-to-directly-call-aspnet-ajax-page-methods/">http://encosia.com/using-jquery-to-directly-call-aspnet-ajax-page-methods/</a></p> <p><a href="http://www.codeproject.com/Articles/287430/Calling-ASP-Net-WebMethods-using-jQuery">http://www.codeproject.com/Articles/287430/Calling-ASP-Net-WebMethods-using-jQuery</a></p> 2012-05-22T03:19:43-04:004991236http://forums.asp.net/p/1805641/4991236.aspx/1?Re+How+to+call+webmethor+using+jquery+Re: How to call webmethor using jquery. <p>Hi,</p> <p>You could use pagemethod. For example:</p> <pre class="prettyprint">[ScriptMethod, WebMethod] public static string GetLabelText() { return &quot;Hello&quot;; } &lt;script type=&quot;text/javascript&quot;&gt; function InsertLabelData() { PageMethods.GetLabelText(onSuccess, onFailure); } function onSuccess(result) { var lbl = document.getElementById('lbl'); lbl.innerHTML = result; } function onFailure(error) { alert(error); } InsertLabelData(); &lt;/script&gt;</pre> <p></p> <p>More details, please refer to: <a href="http://blogs.microsoft.co.il/blogs/gilf/archive/2008/10/04/asp-net-ajax-pagemethods.aspx"> http://blogs.microsoft.co.il/blogs/gilf/archive/2008/10/04/asp-net-ajax-pagemethods.aspx</a>.</p> 2012-05-22T05:27:31-04:00