我的索引视图
@model Maintenance_.Models.IndexModel
@{
ViewBag.Title = "Technician";
}
...Header...
...Ajax Codes...
<div style="border:1px groove #E0EBEB; width:400px;height:330px;float:left;margin-left:20px;"class="scroll-pane">
<table border="1px"style="float:left;">
<thead>
<tr>
<td style ="background-color:#7BB7FA; height:40px;width:150px; border-bottom:5px solid; text-align:center;"><b>Technician No.</b></td>
<td style ="background-color:#7BB7FA; height:40px;width:250px; border-bottom:5px solid; text-align:center;"><b>Technician Name</b></td>
</tr>
</thead>
<tbody>
@{
var altRow = false;
foreach (var item in Model.fNameList)
{
<tr>
<td style ="background-color:@(altRow ? "#fff" : "#E0EBEB"); height:40px;width:100px; padding-left:20px;"><a href ="#" onclick='call("@item.techNo");' style ="text-decoration:none; text-decoration-color:black;"> @item.techNo</a></td>
<td style ="background-color:@(altRow ? "#fff" : "#E0EBEB"); height:40px;width:200px; padding-left:20px;"> @item.firstName @item.lastName</td>
</tr>
altRow = !altRow;
}
}
</tbody>
</table>
</div>
...Content...
<div style="border-radius:20px;border:1px groove #E0EBEB; width:520px;height:100px;float:right;margin-top:15px;">
<div style="margin-top:10px;">Task Options</div>
<div style="margin-top:20px;">
===> <a id="completed"class="btn btn-default" target="_blank" href="@Url.Action("CompletedGrid", "Home")"><i class='fa fa-check fa-fw'></i>Completed</a>
</div>
</div>
如果我点击我的&#34;已完成&#34;它将链接到我的&#34; CompletedGrid&#34;
已完成网格视图
@model Maintenance_.Models.CompletedGridModel
@{
ViewBag.Title = "CompletedGrid";
}
<div id="page-wrapper">
<div class = "row">
<div class = "col-lg-12">
===> <h1 class= "page-header"> Completed @*Technician Name*@</h1>
</div>
</div>
...Content...
这是我的问题:有没有办法将字符串参数传递给另一个视图?使用 @ Url.Action(&#34; CompletedGrid&#34;,&#34; Home&#34;) razor或我应该在控制器中编辑/添加内容?因此,在我的 H1 标记中可以输出&#34;已完成参数&#34;
这是我的控制器和型号。
CompletedGrid的模型
public class CompletedGridModel
{
public string techNo { get; set; }
public string taskNo { get; set; }
public string jobNo { get; set; }
public string grpNo { get; set; }
public string assetNo { get; set; }
public string remarks { get; set; }
public string status { get; set; }
public IList<Maintenance_.Models.CompletedGridModel> CompleteList { get; set; }
}
CompletedGrid的控制器
public ActionResult CompletedGrid(/*Parameter*/)
{
TaskFacade _oTaskFacade = new TaskFacade();
Maintenance_.Models.CompletedGridModel _oCompleteGridModelMODEL = new Maintenance_.Models.CompletedGridModel();
IList<Maintenance_.Models.CompletedGridModel> _oCompletedList = new List<Maintenance_.Models.CompletedGridModel>();
var sample = _oTaskFacade.getTask(_oAppSetting.ConnectionString).ToArray();
foreach (var test in sample)
{
...data transfer...
}
_oCompleteGridModelMODEL.CompleteList = _oCompletedList;
return View("CompletedGrid", _oCompleteGridModelMODEL);
答案 0 :(得分:1)
您可以在索引视图中传递查询字符串
<a id="completed"class="btn btn-default" target="_blank" href="Home/CompletedGrid?value=something">
在控制器中你可以获得查询字符串
public ActionResult CompletedGrid(/*Parameter*/)
{
ViewBag.from= Request.QueryString["value"];
.......
return View("CompletedGrid", _oCompleteGridModelMODEL);
}
在CompletedGrid视图中
<div class = "col-lg-12">
===> <h1 class= "page-header"> Completed @ViewBag.from</h1>
</div>
希望它有所帮助。
答案 1 :(得分:0)
对于网址,始终使用@ Url.Action()而不是&#39; controller / action&#39;
<a id="completed"class="btn btn-default" target="_blank" href="@Url.Action("Home","completedGrid")"+"?value=something">