$("#Name").on("blur", function() {
if (Name != "" && Name != null) {
var options = {
type: "POST",
url: "ApplyNow.aspx/CheckName",
data: "{'Name':'" + $("#Name").val() + "'}",
contentType: "application/json;charset=utf-8",
dataType: "json",
success: function(response) {
onSuccess(response.d, $("#BName"));
},
error: function(msg) { }
};
//execute the ajax call and get a response
$.ajax(options).responseText;
return false;
}
});
});
//the function will execute after the successful ajax submission
function onSuccess(returnText, control) {
if (returnText == 'Error') {
if (control.selector == "#Name") {
alert("'Name' already exists.");
}
control.focus();
control.val("");
return false;
}
else {
return true;
}
}
[WebMethod]
public static string CheckName(string Name)
{
string result = "";
BLAppForm objBLAppForm = new BLAppForm();
try
{
int duplicate = Convert.ToInt32(objBLAppForm.CheckName(Name));
if (duplicate > 0)
{
result = "Error";
return result;
}
else
{
result = "NoDuplicate";
return result;
}
}
catch (Exception ex)
{
Data.SendMailException(ex.Message, "ApplyNow", CheckName
return "Error";
}
}
protected void btnSubmit_Click(object sender, ImageClickEventArgs e)
{
}
how to use the value of 'duplicate' in btnsunmit_click() from webmethod.