本文介绍了如何将两个不同的ViewResults中的两个不同视图发送到MVC中同一页面上的两个不同的tabpages。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的视图中有一个带有两个标签页的标签视图:
I have a tab View with two tab pages on my view as:
<div id="tab">
<ul>
<li><a href="#tabs-ViewBranch">View Branches</a></li><li><a href="#tabs-AddBranch">Add Branch</a></li>
</ul>
<div id="tabs-ViewBranch">
Tab page 1
</div>
<div id="tabs-AddBranch">
@using (Html.BeginForm())
{
@Html.ValidationSummary()
<p>Company Name: @Html.DropDownListFor(x => x.CompanyName, Model.CompanyNames, "Choose an option")</p>
<p>Branch Name: @Html.TextBoxFor(x => x.BranchName)</p>
<p>Branch Code: @Html.TextBoxFor(x => x.BranchCode)</p>
<p>
Branch Type:@Html.DropDownListFor(x => x.BranchType, Model.BranchTypes, "Choose an option")
</p>
<input type="submit" value="Save" />
<input type="button" value="Clear" />
}
</div>
</div>
假设我有两个ActionMethods:
Suppose I have two ActionMethods as:
public ViewResult A()
{
return View(A); //to TabPage 1 (#tabs-ViewBranch")
}
public ViewResult B()
{
return View(B); //to TabPage 2 (#tabs-ViewBranch")
}
我知道如何根据需要路由它们吗?
Any idea how i can route them as desired?
推荐答案
<div id="tabs">
<ul>
<li><a href="#tabs-1">first tab</a></li>
<li><a href="#tabs-2">second tab</a></li>
<li><a href="#tabs-3">third tab</a></li>
</ul>
<div id="tabs-1">
first tab content
</div>
<div id="tabs-2">
second tab content
</div>
<div id="tabs-3">
third tab content
</div>
</div>
Tab内容 -
Tab contents-
<div id="tabs">
<ul>
<li><a href="#tabs-1">first tab</a></li>
<li><a href="#tabs-2">second tab</a></li>
<li><a href="#tabs-3">third tab</a></li>
</ul>
<div id="tabs-1">
@Html.Partial("FirstTabView", Model)
</div>
<div id="tabs-2">
@Html.Partial("SecondTabView", Model)
</div>
<div id="tabs-3">
@Html.Partial("ThirdTabView", Model)
</div>
</div>
-KR
-KR
这篇关于如何将两个不同的ViewResults中的两个不同视图发送到MVC中同一页面上的两个不同的tabpages。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!