Wednesday, August 10, 2011

check a checkbox with Razor

@{

   Model.IsActive = true;

}

@Html.CheckBoxFor(m => m.IsActive, new { IsActive = "true" })

3 comments:

  1. Thanks for ur post... I m new to razor ... can u pls tel me abt what is the advangates of using razor over asp.net ??? I googled it . bt everyone says like reduce key strokes...

    Is it a only advantage over asp.net ???

    ReplyDelete
  2. Fewer keystrokes and thus cleanliness is the advantage. Razor is heavily tied to C# 4.0's anonymous types in its implementation so it is hard for one to imagine it in MVC1. Learning it now is painful, but Microsoft is going forward with Razor as THE way to do things. Writing regular HTML instead of Razor is still OK but try to avoid breaking into <%=

    ReplyDelete