我有一个问题,我有一个传递参数的ajax链接,但是,它打开的页面不需要该参数.页面只加载2个局部视图,其中一个需要传递给页面的参数才能正确加载数据,另一个只需要加载一个表单,因此,不需要该参数.我怎么能做到这一点?
为了做你想做的事,你需要将id添加到ViewData构造中.
var sysfunctions= UnisegurancaService.FunctionsRepository.All();
ViewData["NeededID"] = id
return View(sysfunctions);
Run Code Online (Sandbox Code Playgroud)
然后在你的视图中渲染局部
<%= Html.RenderPartial("GridFunction", (int)ViewData["NeededID"]) %>
Run Code Online (Sandbox Code Playgroud)
当然要按照要求施放.
随着第二个参数成为部分中的.Model而被推入的任何东西.我建议也强烈输入你的部分内容.
小智 0
//控制器
public ActionResult EditFunctions(int id)
{
var sysfunctions= UnisegurancaService.FunctionsRepository.All();
return View(sysfunctions);
}
// This is the controller (it does no need the parameter "ID")
Run Code Online (Sandbox Code Playgroud)
//这是视图“EditFunctions”
<div id="formFunction">
<% Html.RenderPartial("FormFunction"); %>
</div>
<div id="gridFunction">
<% Html.RenderPartial("GridFunction"); %> // The grid needs the ID to work correctly but its in the parent page not in the partial call....and the call is an ajax call
</div>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11241 次 |
| 最近记录: |