如何将razor中的值传递给C#类?
我想将KeyPath
中的值传递给autoCreateSoldPart
,但我不知道该怎么做。
剃刀
soldPartSetting
剃刀控制器
<p>
@Html.Label("Auto recreate sold part", new { @for= "autoCreateSoldPart" })
@{
var lstSelect = new List<SelectListItem>()
{
new SelectListItem() { Text = "Yes", Value = "true" },
new SelectListItem() { Text = "No", Value = "false" }
};
lstSelect.ForEach(o =>
{
if (o.Value == System.Configuration.ConfigurationManager.AppSettings["ReCreateSoldPart"])
{
o.Selected = true;
}
});
}
@Html.DropDownList("autoCreateSoldPart", lstSelect, new { @class = "form-control" })
</p>
C#
public class HomeController : Controller
{
public ActionResult Settings()
{
ViewBag.Message = return View();
}
}