Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
All-Star
15088 Points
2277 Posts
Microsoft
Moderator
Nov 27, 2010 04:54 PM|LINK
This hack works until I can come up with something better.
In my case I have IsUID_Available2(string FirstName) as the wrapper method with the 2nd field name.
[OutputCache(Location = OutputCacheLocation.None, NoStore = true)] public class ValidationController : Controller { public JsonResult IsUID_Available(string Username) { if (UserNameHelper.IsAvailable(Username)) return Json(true, JsonRequestBehavior.AllowGet); string suggestedUID = String.Format(CultureInfo.InvariantCulture, "{0} is not available.", Username); for (int i = 1; i < 100; i++) { string altCandidate = Username + i.ToString(); if (UserNameHelper.IsAvailable(altCandidate)) { suggestedUID = String.Format(CultureInfo.InvariantCulture, "{0} is not available. Try {1}.", Username, altCandidate); break; } } return Json(suggestedUID, JsonRequestBehavior.AllowGet); } public JsonResult IsUID_Available2(string FirstName) { return IsUID_Available(FirstName); } }
ricka6
All-Star
15088 Points
2277 Posts
Microsoft
Moderator
Re: CustomValidation?
Nov 27, 2010 04:54 PM|LINK
This hack works until I can come up with something better.
In my case I have IsUID_Available2(string FirstName) as the wrapper method with the 2nd field name.
[OutputCache(Location = OutputCacheLocation.None, NoStore = true)] public class ValidationController : Controller { public JsonResult IsUID_Available(string Username) { if (UserNameHelper.IsAvailable(Username)) return Json(true, JsonRequestBehavior.AllowGet); string suggestedUID = String.Format(CultureInfo.InvariantCulture, "{0} is not available.", Username); for (int i = 1; i < 100; i++) { string altCandidate = Username + i.ToString(); if (UserNameHelper.IsAvailable(altCandidate)) { suggestedUID = String.Format(CultureInfo.InvariantCulture, "{0} is not available. Try {1}.", Username, altCandidate); break; } } return Json(suggestedUID, JsonRequestBehavior.AllowGet); } public JsonResult IsUID_Available2(string FirstName) { return IsUID_Available(FirstName); } }