• 转:MVC2表单验证失败后,直接返回View,已填写的内容就会清空,可以这样做;MVC2输出文本;MVC2输出PDF文件



    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;变成不选中状态。

  • 相关阅读:
    乱七八糟
    堆-heap
    转linux文件的读写
    @转EXT2->EXT3->EXT4
    (转)僵死进程与孤儿进程
    java
    poj-1062-昂贵的聘礼
    java 之 wait, notify, park, unpark , synchronized, Condition
    事物(笔记)
    BPX-tree
  • 原文地址:https://www.cnblogs.com/joeylee/p/3469843.html
Copyright © 2020-2023  润新知