Getting Started with Adobe After Effects - Part 6: Motion Blur
A collection of quick technology learning tips from what people around you learn every day

asp.net mvc 3.0 remote attribute

Nov 12 2011 8:35AM by Solanki Bhavik A.   

Often in web applications, while validating the data at client side, we often have the scenario of calling a function, which is implemented in server side. For example, we might want to validate the entered user name is already exists in our database. To facilitate these types of requirements, MVC 3.0 introduce new tag "remote" which we will easily use for customer validation on client side in mvc 3.0

 public class UserInformation
{
[Required]
[System.Web.Mvc.Remote("IsUserNameExits", "Validation")]
public string Name { get; set; }
}
 public JsonResult IsUserNameExits(string Name)
{

//you can write code for check in database

if (Name == "Bhavik")
{
return Json("Sorry UserName Already Taken", JsonRequestBehavior.AllowGet);

}
else
{
return Json(true, JsonRequestBehavior.AllowGet);
}
}
Read More..   [20 clicks]

Published under: Microsoft .NET Tips ·  ·  ·  · 


Solanki Bhavik A.
155 · 1% · 310
5
 
0
Knew
 
 
0
Incorrect
 
0
Interesting
 
0
Forgotten



Submit

8  Comments  

  • Thanks Bhavik,

    So many times i had this requirement. But unfortunate, in my projects we are not using MVC.

    Very useful..

    commented on Nov 12 2011 8:37AM
    Ramireddy
    2 · 41% · 12972
  • Hi,

    i am very happy if some one like my post and i am always ready to help and share knowledge. Regards, bhavik

    commented on Nov 13 2011 10:24AM
    Solanki Bhavik A.
    155 · 1% · 310
  • Hii,

    Thank you for posting this information. I would like to add some more to this. I face problem with remote that function not get executed when page comes from cache. To execute validation function each time , need to mention [OutputCache(Location = System.Web.UI.OutputCacheLocation.None, NoStore = true)] in just above the validation function.

    In above example like this [OutputCache(Location = System.Web.UI.OutputCacheLocation.None, NoStore = true)] public JsonResult IsUserNameExits(string Name) { }

    commented on Nov 13 2011 10:17PM
    DHARA Gandhi
    1496 · 0% · 13
  • Yes it true thanks for info. i have just check

    commented on Nov 13 2011 10:25PM
    Solanki Bhavik A.
    155 · 1% · 310
  • Good one Bhavik

    commented on Nov 13 2011 11:40PM
    Kirti M.Darji
    10 · 16% · 4985
  • Thanks Kirti bhai. Actually i have start learning for mvc 3.0 razor for my new project.

    commented on Nov 13 2011 11:49PM
    Solanki Bhavik A.
    155 · 1% · 310
  • I will be doing a new project soon too in ASP.NET MVC I've been watching PluralSight videos to help me get started.

    commented on Nov 16 2011 2:11PM
    Naomi
    33 · 6% · 1774
  • it's really very good you can also check my blog where i will make post update which i have done in mvc Blog link text

    and here is best link to learn mvc :http://www.asp.net/mvc

    Regards, Bhavik

    commented on Nov 16 2011 10:46PM
    Solanki Bhavik A.
    155 · 1% · 310

Your Comment


Sign Up or Login to post a comment.

"asp.net mvc 3.0 remote attribute" rated 5 out of 5 by 5 readers
asp.net mvc 3.0 remote attribute , 5.0 out of 5 based on 5 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]