Translate

2014年3月11日 星期二

MVC Javascript alert return


It's a simple example :

public ActionResult AlertMsg(string id)
{
  string url = Url.Content("~/Area/Control/AlertMsg/" + id);
  return Content(string.Format("<script>alert('ok'); window.location.href='{0}'",url)</script>","text/html");
}

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();
}