Hi, I am using MVC Application, in that I am validating user name to prevent Duplicate names from database. Just I need to show message box or somthing
My JavaScript code:
<script type="text/javascript">
$(document).ready(function () {
$("#CheckAvailabilty").click(function () {
var ds = ($("#txtLoginname").val());
$.ajax({ url: '/Home/StaffCheckAvailabilty?Staffname=' + ds,
type: "Post",
dataType: "json",
success: function (rtbs) {
alert (message);
$("#txtPassword").get(0).value = rtbs[0].value;
}
});
});
});
</script>
C# code:
public string rtbs;
public ActionResult StaffCheckAvailabilty(ModelGridAllFeatures model, string Staffname)
{
var query1 = DB_Linq.TblStaffPersonalDetails
.Where(s => s.LoginName == Staffname)
.Select(s => new { s.StaffName, s.ActiveFlag });
int name = query1.Count();
//var rtbs;
if (name != 0)
{
Response.Write("Login Name already Exists");
rtbs = "Login Name already Exists";
}
else
{
Response.Write("Available");
rtbs = "Available";
}
return Json(rtbs);
}
I am returing rtbs but its not showing alert message
public ActionResult StaffCheckAvailabilty(Mand$.ajax({ url: '/Home/StaffCheckAvailabilty?Staffname=' + ds,dont you think there is a difference in the url and the ActionResult?