How to call sharepoint webpart usercontrol method in AJAX
$.ajax({
type: "POST",
url: "FundUserRegister2.asmx\validateEmail",
data: "{'strMailID': '" + $('#<%= txtEmail.ClientID %>').val() + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (message) {
alert(message.d);
}, error: function (message) {
alert(message.d);
}
});
method is as following
[WebMethod]
public static string validateEmail(string strMailID)
{
if (string.IsNullOrEmpty(strMailID))
{
string pwdRandom = DateTime.Now.ToString("htffffsH");
MembershipCreateStatus status;
MembershipUser newUser = Membership.CreateUser(strMailID, pwdRandom, strMailID, null, null, false, out status);
if (status == MembershipCreateStatus.Success)
return "true";
else
return "false";
}
else
{
return "false";
}