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
Remote validation not woking
Oct 20 2016 2:29 AM
Hi all,i try this code for checking username already is there are not
public ActionResult CheckForDuplication(string UserName)
{
SqlConnection con = new SqlConnection(s);
SqlCommand cmd = new SqlCommand("Sp_CheckForDuplication", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@UserName", UserName);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.HasRows)
{
return Json("Sorry UserName not aviable", JsonRequestBehavior.AllowGet);
}
else
{
return Json(true, JsonRequestBehavior.AllowGet);
}
and in my model
[Required(ErrorMessage = "*")]
[StringLength(20, MinimumLength = 4, ErrorMessage = "Must be at least 4 characters long.")]
[Remote("CheckForDuplication", "OutLet", HttpMethod = "POST", ErrorMessage = "User name already exists. Please enter a different user name.")]
so when i m trying to execiute it it wont hits the method ..any help please
thanks and regards
Reply
Answers (
3
)
Db saves only first letter of the record
WebForms UnobtrusiveValidationMode requires a ScriptResource