Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post May 22, 2012 05:27 AM by Song-Tian - MSFT
0 Points
1 Post
May 21, 2012 05:03 AM|LINK
Hello.
$('#txtMbUser').click(function () { var username = $('#txtMbUser').val(); $.ajax({ type: "POST", url: "FormMbRegister.ascx/Usercheck", data: "username: '" + username + "'", contentType: "application/json; charset=utf-8", dataType: "json", success: function (msg) { alert(msg); }, Error: function(){ alert('loi'); } }); });
#region [Check User, Email exits] [WebMethod] public static string Usercheck(string username) { return "Called"; } #endregion
It is do not work.
Participant
790 Points
138 Posts
May 21, 2012 05:30 AM|LINK
With Reference to this post ,
http://forums.asp.net/t/1795796.aspx/1
i say that
"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."
All-Star
65759 Points
11153 Posts
May 22, 2012 03:19 AM|LINK
Refer this
http://encosia.com/using-jquery-to-directly-call-aspnet-ajax-page-methods/
http://www.codeproject.com/Articles/287430/Calling-ASP-Net-WebMethods-using-jQuery
43697 Points
4304 Posts
Microsoft
May 22, 2012 05:27 AM|LINK
Hi,
You could use pagemethod. For example:
[ScriptMethod, WebMethod] public static string GetLabelText() { return "Hello"; } <script type="text/javascript"> function InsertLabelData() { PageMethods.GetLabelText(onSuccess, onFailure); } function onSuccess(result) { var lbl = document.getElementById('lbl'); lbl.innerHTML = result; } function onFailure(error) { alert(error); } InsertLabelData(); </script>
More details, please refer to: http://blogs.microsoft.co.il/blogs/gilf/archive/2008/10/04/asp-net-ajax-pagemethods.aspx.
DucThong
0 Points
1 Post
How to call webmethor using jquery.
May 21, 2012 05:03 AM|LINK
Hello.
$('#txtMbUser').click(function () { var username = $('#txtMbUser').val(); $.ajax({ type: "POST", url: "FormMbRegister.ascx/Usercheck", data: "username: '" + username + "'", contentType: "application/json; charset=utf-8", dataType: "json", success: function (msg) { alert(msg); }, Error: function(){ alert('loi'); } }); });#region [Check User, Email exits] [WebMethod] public static string Usercheck(string username) { return "Called"; } #endregionIt is do not work.
Usman Amir
Participant
790 Points
138 Posts
Re: How to call webmethor using jquery.
May 21, 2012 05:30 AM|LINK
With Reference to this post ,
http://forums.asp.net/t/1795796.aspx/1
i say that
"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."
chetan.sarod...
All-Star
65759 Points
11153 Posts
Re: How to call webmethor using jquery.
May 22, 2012 03:19 AM|LINK
Refer this
http://encosia.com/using-jquery-to-directly-call-aspnet-ajax-page-methods/
http://www.codeproject.com/Articles/287430/Calling-ASP-Net-WebMethods-using-jQuery
Senior Software Engineer,
Approva Systems Pvt Ltd, Pune, India.
Song-Tian - ...
All-Star
43697 Points
4304 Posts
Microsoft
Re: How to call webmethor using jquery.
May 22, 2012 05:27 AM|LINK
Hi,
You could use pagemethod. For example:
[ScriptMethod, WebMethod] public static string GetLabelText() { return "Hello"; } <script type="text/javascript"> function InsertLabelData() { PageMethods.GetLabelText(onSuccess, onFailure); } function onSuccess(result) { var lbl = document.getElementById('lbl'); lbl.innerHTML = result; } function onFailure(error) { alert(error); } InsertLabelData(); </script>More details, please refer to: http://blogs.microsoft.co.il/blogs/gilf/archive/2008/10/04/asp-net-ajax-pagemethods.aspx.
Feedback to us
Develop and promote your apps in Windows Store