ASP.NET MVC , Razor and Validations!!

Just created a sample to showcase EF 4.0 Code First so happens that the app made to showcase uses the MVC 3.0 pattern with Razor implementation .

So why not highlight a few points there too.

  1. Goodbye <%=%> , hello @
    @Model.IdeaTitle +":"+@Model.Description+" :"+ @Model.SubmittedBy 

  1. Server tag commenting…
        ViewBag.Title = "Index";

  2. ViewBag plus View
     public ActionResult Index()
       IdeaContext context= new IdeaContext();
        var j = context.Ideas;
        ViewBag.Title = " Idea List";
        return View(j.ToList());

@model IEnumerable<IdeaMVC.Models.IdeaModel>


4.   User Controls..

@Html.Partial("_DetailsPartialPage", Model)

5. Server side validation using Annotations (Server Side)

 public ActionResult Create(IdeaModel  idea)
        if (ModelState.IsValid)

6. Client Side Validatation

<script src="@Url.Content("~/Scripts/MicrosoftAjax.js")" type ="text/javascript"></script>
<script src="@Url.Content("~/Scripts/MicrosoftMvcAjax.js")" type ="text/javascript"></script>
<script src="@Url.Content("~/Scripts/MicrosoftMvcValidation.js")" type ="text/javascript"></script>


7. Layout..

  <div id="main">
            <div id="footer">

    Layout = "~/Views/Shared/_Layout.cshtml";

Small snippets to showcase changes…There are of course many more changes/improvements but then the intention was to showcase Code First Entity Framework…a Full Fledged MVC 3.0 coming up soon..

Incase you want the full app for download (this plus Code First EF) do drop me a mail..


About Cennest
Cennest is the brainchild of a group of IT Professionals keen to try their hand in the world of IT Freelancing. After working in the corpora

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: