TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
aditya immadi
NA
215
23.8k
ajax calls for checking existing email or name
Jun 13 2016 3:13 AM
Hai all i wrote this for calling rmail is exists or not in my db
$(document).ready(function () {
function NameChecking() {
var name= $("#<%=TxtName.ClientID%>").value;
alert(name)
$.ajax({
type: "POST",
url: "Default.aspx/CheckEmail",
data: '{Name: "' + $("#<%=TxtName.ClientID%>")[0].value + '" }',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: function (response) {
alert(response);
}
});
}
<asp:TextBox ID="TxtName" runat="server" onchange="NameChecking();" AutoPostBack="false" CausesValidation="True" ClientIDMode="Static"></asp:TextBox>
and mmy .cs file is
[System.Web.Services.WebMethod]
public static string CheckEmail(string Name)
{
string s = ConfigurationManager.ConnectionStrings["con"].ConnectionString;
string result = "";
SqlConnection con = new SqlConnection(s);
SqlCommand cmd = new SqlCommand("SP_CheckName", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@Name", Name);
con.Open();
SqlDataReader dr = cmd.ExecuteReader();
if (dr.HasRows)
{
result = "true";
}
else
{
result = "false";
}
return result;
but the method
namechecking
is not firing which is in textbox control
any leads..
TIA
Reply
Answers (
4
)
How to solve this common error
ViewData, ViewBag and TempData in MVC ( Reference )