ASP.NET MVC 入门7、Hellper与数据的提交与绑定
2020-12-13 15:35
标签:des style class blog code http 生成的HTML代码就是:首页 参考:http://www.cnblogs.com/QLeelulu/archive/2008/10/05/1303991.html ASP.NET MVC 入门7、Hellper与数据的提交与绑定,搜素材,soscw.com ASP.NET MVC 入门7、Hellper与数据的提交与绑定 标签:des style class blog code http 原文地址:http://www.cnblogs.com/ybtools/p/3796519.html
p>
label for="Name">Blog的名称label>
=Html.TextBox("Name")%>
=Html.ValidationMessage("Name")%>
p>
p>
label for="Description">Blog的简单描述label>
=Html.TextArea("Description")%>
=Html.ValidationMessage("Description")%>
p>
p>
label for="PostsPerPage">每页显示的日志数label>
=Html.TextBox("PostsPerPage")%>
=Html.ValidationMessage("PostsPerPage")%>
p>
[ActionName("Setting"), AcceptVerbs("POST")]
public ActionResult SaveSetting()
{
//当然你可以这样取值
//string name = Request.Form["Name"];
//但我们有更简便的:
try
{
UpdateModel(BlogSettings.Instance, new[] { "Name", "Description", "PostsPerPage" });
}
catch
{
return View(BlogSettings.Instance);
}
//在这里你可能还需要对自定义的业务逻辑进行验证
BlogSettings.Instance.Save();
return ShowMsg(new Liststring>() { "修改设置成功" });
}
上一篇:快速傅里叶变换c语言版
文章标题:ASP.NET MVC 入门7、Hellper与数据的提交与绑定
文章链接:http://soscw.com/index.php/essay/35257.html