ViewData.ModelState.AddModelError("FormValidator", message); foreach (string field in Request.Form.Keys)
{
ViewData.Add(field, Request.Form[field].Trim());
}
然后Form中用HtmlHelper创建的Input控件会自动从ViewData中获取value。
2)输出纯文本:return Content(message, "text/plain", Encoding.UTF8); 或者
return new ContentResult { Content = message, ContentType = "text/plain", ContentEncoding = Encoding.UTF8 };
显示PDF文件:
return File("~/Content/developersguide.pdf", "application/pdf", "developersguide.pdf");
3)HTML的select元素默认第一个选项是选中的,需要javascript执行oSelect.selectedIndex = -1;变成不选中状态。