Tech
Forums
Jobs
Books
Events
Videos
Conference
Annual Conference
Bcrypt
Ai Conference
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
11
Answers
check user name with jquery not hitting method
Ask a question
Ask a question
Upload Source Code:
Select only zip and rar file.
aditya immadi
7y
398
1
Reply
hiall,
i wrote this for checking use name avialbiityy .the name with alert is pop up but the method in my controller not hitting any leads
function check() {
var Name = $("#checkid").val();
alert(Name);
$.ajax({
type: "POST",
url: "home/checkname/",
data: '{ UserName: Name }',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: function (response) {
alert(Name);
}
});
}
and in my controller
[AllowAnonymous]
public string checkname(string UserName)
{
SqlConnection con = new SqlConnection(s);
SqlCommand cmd = new SqlCommand("select UserName From tbl_Login where UserName=@Name", con);
cmd.Parameters.AddWithValue("@Name", UserName);
con.Open();
SqlDataReader d = cmd.ExecuteReader();
if (d.HasRows)
{
return "fine";
}
else
{
return "****";
}
}
Thanks and Regard
Post
Reset
Cancel
Answers (
11
)
Next Recommended Forum
Get values from post data in asp.net
How I can give option in popup when send an email in ASP.NET