Nop Commerce RenderBootstrapTabHeader提交

时间:2016-10-27 13:45:57

标签: c# html razor nopcommerce

我在NopCommerce v3.8中的自定义插件中有以下代码。

@using Nop.Web.Framework;
@using Nop.Core;
@using System.Linq;
@using Nop.Web.Framework.UI;
@using Nop.Web.Framework;
@using Nop.Core.Infrastructure;
@model Nop.Plugin.Widgets.PromoSlider.Domain.PromoSliderRecord

@{ Layout = "_AdminLayout.cshtml"; }

<div class="content">
<div class="form-horizontal">
    <div id="slider-edit" class="nav-tabs-custom">
        <ul class="nav nav-tabs">
            @Html.RenderBootstrapTabHeader("Slider", @T("Slider"), true)
            @Html.RenderBootstrapTabHeader("Images", @T("Images"))
        </ul>
        <div class="tab-content">
            @Html.RenderBootstrapTabContent("Slider", Sliders(), true)
            @Html.RenderBootstrapTabContent("Images", Images(), false)
        </div>
    </div>
</div>
</div>


@helper Sliders()
{
using (Html.BeginForm())
{
    @Html.AntiForgeryToken()

    <div class="panel-group">
        <div class="panel panel-default">
            <div class="panel-body">
                <div>
                    <div class="adminData">@Html.HiddenFor(m => m.PromoSliderId)</div>
                </div>
                <div class="form-group">
                    <div class="col-md-2">@Html.NopLabelFor(m => m.PromoSliderName)</div>
                    <div class="col-md-9">
                        @Html.EditorFor(m => m.PromoSliderName)
                        @Html.ValidationMessageFor(m => m.PromoSliderName)
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-md-2">@Html.NopLabelFor(m => m.IsActive)    </div>
                    <div class="col-md-9">
                        @Html.EditorFor(m => m.IsActive)
                        @Html.ValidationMessageFor(m => m.IsActive)
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-md-2">@Html.NopLabelFor(m => m.Interval)</div>
                    <div class="col-md-9">
                        @Html.EditorFor(m => m.Interval)
                        @Html.ValidationMessageFor(m => m.Interval)
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-md-2">@Html.NopLabelFor(m => m.Wrap)</div>
                    <div class="col-md-9">
                        @Html.EditorFor(m => m.Wrap)
                        @Html.ValidationMessageFor(m => m.Wrap)
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-md-2">@Html.NopLabelFor(m => m.PauseOnHover)</div>
                    <div class="col-md-9">
                        @Html.EditorFor(m => m.PauseOnHover)
                        @Html.ValidationMessageFor(m => m.PauseOnHover)
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-md-2">@Html.NopLabelFor(m => m.ZoneName)</div>
                    <div class="col-md-9">
                        @Html.DropDownListFor(m => m.ZoneName, new SelectList(
                    new List<string>() {
                        "producdivetails_top",
                        "categorydetails_after_breadcrumb",
                        "home_page_top"
                    }))
                        @Html.ValidationMessageFor(m => m.ZoneName)
                    </div>

                </div>
                <div class="pull-right">
                    <button type="submit" name="save" class="btn bg-blue">
                        <i class="fa fa-floppy-o"></i>
                        @T("DERP")
                    </button>
                </div>
            </div>
        </div>
    </div>                     
}

}

@helper Images()
{
if (Model.PromoSliderId > 0)
{
    @Html.Action("ManagePromoImages", new { PromoSliderId = Model.PromoSliderId })
}
else
{
    <p>Please create and save a slider first.</p>
}

}

提交按钮根本不会触发,可以通过查看生成的源找到原因。

<div class="content">
<div class="form-horizontal">
    <div id="slider-edit" class="nav-tabs-custom">
        <ul class="nav nav-tabs">
            <li class="active"><a data-tab-name="Slider" data-toggle="tab" href="#Slider">slider</a></li>
            <li class=""><a data-tab-name="Images" data-toggle="tab" href="#Images">images</a></li>
        </ul>
        <div class="tab-content">
            <form action="/PromoSlider/CreateUpdatePromoSlider" method="post"></form><div class="tab-pane active" id="Slider"><input name="__RequestVerificationToken" type="hidden" value="uH2GbG4t6n0dDyBs79d6GQZTorBRpgWFCFithR77gSkAUYvPkMecNIwYtkEGyayid97gmdQp-isUUkMq1M7qSpeYOzwLGW-9WtUIxggkBd-0gATnIt5CvfEtUpjqwnl90" />        <div class="panel-group">
        <div class="panel panel-default">
            <div class="panel-body">
                <div>....

正如您所看到的那样,它决定创建表单,然后关闭它并在表单后输入所有@helper html代码,包括提交按钮。

我的问题,你还能使用

吗?
  

@ Html.BeginForm

里面的

  

@ Html.RenderBootstrapTabHeader

真的很想让这个工作在3.8感谢。

2 个答案:

答案 0 :(得分:2)

我现在唯一可以提供的方法是使用带有必需参数的<form></form>标记在@helper {}内创建表单。 我们已经创建了一个适当的问题来调查此问题: https://github.com/nopSolutions/nopCommerce/issues/1840

答案 1 :(得分:0)

enter image description here您可以添加@Html.BeginForm 在您在顶部声明的标签中,两者都可以正常工作

你可以从这个截图中了解