使用mvc Razor在Tabs中发送表单

时间:2014-03-25 23:50:46

标签: jquery asp.net-mvc twitter-bootstrap tabs

我正在开发一个网站,而且我是MVC的新手,我使用的是MVC4,在我的代码中,我创建了一个PartialView,我放了4个标签,每个标签都是部分视图,我能填写3个表格,我的所有组合框都填写正确,我的问题是提交标签的内容,因为我有3个表单,我无法将信息提交给我数据库,提交按钮应该在主视图上。

我在Member.cshtml上添加了BeginForm以封装Tabs,我在最后添加了提交,但是当我点击提交时,我看到了模型的内容,我从组合或输入中选择的所有值字段为空。

你能帮助我吗?几天来我一直没有成功地寻找结果。

在我的模型中我有:CommandLineItems

public class CommandLineItems
{
 public GeneralInfo CLGeneralInfo { get; set; }
 public GeneralColor CLGeneralColor { get; set; }
 public General1    CLGeneral1{ get; set; }
}

主视图包含(Member.cshtml):

@model WebApp.Models.CommandLineItems
<div id="Maintabs">
    <ul id="MyTab" class="nav nav-tabs">
        <li class="active"><a data-toggle="tab" href="#GeneralTab">General info</a></li>
        <li class=""><a data-toggle="tab" href="#ColorTab">Colors</a></li>
        <li class=""><a data-toggle="tab" href="#Tab1" id="1" style="display: none">1</a></li>
    </ul>
    <div class="tab-content">
        <div class="tab-pane active" id="GeneralTab">
            @Html.EditorFor(x => x.CLGeneralInfo, "_GeneralInformation")
        </div>
        <div class="tab-pane" id="ColorTab">
            @Html.EditorFor(x => x.CLGeneralColor, "_GeneralColorView")
        </div>
        <div class="tab-pane" id="Tab1">
            @Html.EditorFor(x => x.CLGeneral1, "1")
        </div>
    </div>
</div>

“常规”选项卡视图是:

@model WebApp.Models.GeneralInfo
@using (Html.BeginForm())
{
@Html.ValidationSummary(true)
<section id="content">
    <form class="form_validation">
        <div class="span6">
            <label>PO</label>
            @Html.EditorFor(model => model.PO)
        </div>
        <div class="span6">
            <label>Line</label>
            @Html.EditorFor(model => model.Line)
        </div>
        <label>League </label>
        <div class="controls">
            @Html.DropDownListFor(model => model.Type, WebApp.Models.TypeTypeList())
        </div>
    </form>
</section>
}

“颜色”选项卡视图:

@model WebApp.Models.GeneralColor
@using (Html.BeginForm()){
    @Html.ValidationSummary(true)
    <section id="content">
        <form class="form_validation">
                <div class="span4">
                    <label>@Html.LabelFor(m => m.ColorPants)</label>
                    @Html.DropDownListFor(model => model.ColorPants, Model.AllColors})

                </div>
                <!--2eme col-->
                <div class="span4">
                    <label>@Html.LabelFor(m => m.ColorShoes)</label>
                    @Html.DropDownListFor(m => m.ColorShoes,  Model.AllColors)
                </div>
        </form>
    </section>
}  

我有一个与CLGeneral1的BeginForm相同的部分视图。

由于

0 个答案:

没有答案