C# MVC表单参数的传值过程

37 篇文章 0 订阅
7 篇文章 0 订阅

1.   /Views/LocalParam/Index.cshtml

开头引用模板

@model UIH.PACS.Server.Web.Models.BaseParamsVM

带参数的表单使用htmlHelp类实现

@using (Html.BeginForm("Edit", "LocalParam", FormMethod.Post))
{
    <div class="grayBG EditInfoSetting LayoutMunSet" name="mainsetting">
        @Html.ValidationSummary(true)
        <h3>
            本机参数设置</h3>
        <div class="editor-label">
            @Html.LabelFor(model => model.BaseParams.OurAETitle)&nbsp;:&nbsp;
            @Html.EditorFor(model => model.BaseParams.OurAETitle)
            <text style="color: red">*</text>
            @Html.ValidationMessageFor(model => model.BaseParams.OurAETitle)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.BaseParams.Timeout)&nbsp;:&nbsp;
            @Html.EditorFor(model => model.BaseParams.Timeout)
            @Html.ValidationMessageFor(model => model.BaseParams.Timeout)
        </div>
        <h3>
            转发设置
        </h3>
        <div class="editor-label" ignore>
            <label class="MG42">@Html.CheckBoxFor(model => model.BaseParams.IsEnableFtpTransfer)</label>
            @Html.LabelFor(model => model.BaseParams.IsEnableFtpTransfer)
        </div>
        <div class="editor-label" ignore style="display: none">
            <label class="MG42">@Html.CheckBoxFor(model => model.BaseParams.IsAutoRoutedMpps)</label>
            @Html.LabelFor(model => model.BaseParams.IsAutoRoutedMpps)
        </div>
        @Html.HiddenFor(model => model.BaseParams.MailServerType)
        @Html.HiddenFor(model => model.BaseParams.SenderMailAddress)
        @Html.HiddenFor(model => model.BaseParams.SenderMailPassword)
        @Html.HiddenFor(model => model.BaseParams.RecieverMailAddress)
        @Html.HiddenFor(model => model.BaseParams.LogMailTitle)
        @Html.HiddenFor(model => model.BaseParams.PACSType, new { @id = "oldPacsType" })
    </div>
    <div class="grayBG EditInfoSetting LayoutMunSet" style="display: none" name="extsetting">
        @Html.Partial("_ExtendSet")
    </div>
       ··········
        ·········
}

2. 指向模板中 /Models/BaseParamsVM.cs

namespace UIH.PACS.Server.Web.Models
{
    [Serializable]
    public class BaseParamsVM
    {
        /// <summary>
        /// 基础参数配置
        /// </summary>

        //在LocalParams中设置基本参数
        public LocalParams BaseParams { get; set; }

        /// <summary>
        /// 转发策略
        /// </summary>
        public IPagedList<ROUTE_CONTROL> RouteControlList { get; set; }

        public string CompressAlgorithm { get; set; }
        public string RouteCompressAlgorithm { get; set; }

        public string ConsoleLogLevel { get; set; }
        public string DatabaseLogLevel { get; set; }
        public string FileLogLevel { get; set; }
        public string MailLogLevel { get; set; }
        public string WindowsLogLevel { get; set; }
        public string PACSMode { get; set; }
        public string PACSType { get; set; }
        public int StorageMode { get; set; }
    }

    public class RouteIndexParameters
    {
        public int RoutePage { set; get; }
        public int RoutePageCount { set; get; }
    }

    public class RouteData
    {
        public string srcAE { set; get; }
        public string destinationAE { set; get; }
        public string routeImmediately { set; get; }
        public string routeTime { set; get; }
        public string oldSrcAE { set; get; }
        public string oldDestinationAE { set; get; }
        public string ID { set; get; }
        public string routeType { set; get; }
        public string duration { set; get; }
    }
}

其中的基本参数由 /Models/LocalParams.cs 设置

3. form表单submit之后,后台的controller就开始进行表单验证等工作,完毕后使用json的方式将数据返回前台

/Controller/LocalParamController.cs

return Json(bool, function());

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值