Translate

顯示具有 Razor 標籤的文章。 顯示所有文章
顯示具有 Razor 標籤的文章。 顯示所有文章

2014年3月7日 星期五

MVC RadioButton

RadioButton like this:

only one of predefined set of options

ex.

.cshtml [View]

        @Html.RadioButton("food", "steak", true)
            steak
        @Html.RadioButton("food", "hamburger", false)
            humbuger
        @Html.RadioButton("food", "pasta", false)
            pasta


.cs [Controller]

//string food will be selected steak or hamburger or pasta
ActionResult EditMenu(string id, string food)
{
  return View();
}

2012年7月30日 星期一

MVC Razor

ref→http://weblogs.asp.net/scottgu/archive/2010/12/15/asp-net-mvc-3-razor-s-and-lt-text-gt-syntax.aspx

先記一下,MVC相關語法

若要從routerView取得id資料
@ViewContext.RouteData.Values["Id"]

若要從Cotroller取得id資料
this.RouteData.GetRequiredString("id")

祝學習愉快