从页面到局部视图asp.net的MVC参数 [英] asp.net mvc parameter from page to a partial view

查看:219
本文介绍了从页面到局部视图asp.net的MVC参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一个问题,我有一个传递一个参数阿贾克斯联系,但是,它打开不需要该参数的页面。该页面只装2部分景色,其中的一个需要一个参数传递到页面正确加载数据,另一个只需要加载一个形式,所以,不需要该参数。我怎样才能达致这?

I'm with a problem, I have a ajax link that pass a parameter, but, the page that it opens does not need that parameter. The page only load 2 partial views, one of those need that parameter passed to the page to load the data correctly, and the other just need to load a form, so, don't need that parameter. How can i acheive this?

推荐答案

为了做你想做什么,你需要将ID添加到ViewData的结构。

In order to do what you want, you will need to add the id to the ViewData construct.

var sysfunctions= UnisegurancaService.FunctionsRepository.All();
ViewData["NeededID"] = id
return View(sysfunctions);

然后在你看来,你渲染部分

then in your view where you render the partial

<%= Html.RenderPartial("GridFunction", (int)ViewData["NeededID"]) %>

演员作为必修课。

Cast as required of course.

无论被推作为第二个参数成为局部的。型号。我建议也强烈输入您的谐音。

Whatever gets pushed in as the second param becomes the .Model in the partial. I would suggest also strongly typing your partials.

这篇关于从页面到局部视图asp.net的MVC参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆