如何在Mvc Razor视图中创建多个部分视图 [英] How Do I Create More Than One Partial Views In Mvc Razor View

查看:87
本文介绍了如何在Mvc Razor视图中创建多个部分视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友们,



i是MVC新手,



i我正在使用两个局部视图两个用户控件让它成为第一个和第二个,实际上它应该通过该URL从用户控件获取数据,具体取决于查询字符串。

问题是在我运行页面时,第一个和第二个部分视图显示相同的值(正好是第一个显示的)





@ Html.Partial(〜/ Views / Shared / _first.vbhtml )它将引用.ascx文件的URL



@ Html.Partial(〜/ Views / Shared / _second.vbhtml)



所以请给我一个解决方案,如果你需要更多,请确保我会



提前感谢



Velsamy A

Hi Friends,

i am new to MVC,

i am using two partial view s for two user controls let it be first and second, actually it should fetch the data from the user controls through that URL depending upon the query string.
problem is while i run the page, both first and second partial view displaying same value(exactly what first one shows)


@Html.Partial("~/Views/Shared/_first.vbhtml") it will refer the .ascx file's url

@Html.Partial("~/Views/Shared/_second.vbhtml")

so give me a solution please, if you need more , sure i will

thanks in advance

Velsamy A

推荐答案

1.在MVC中,您可以在同一视图中使用更多局部视图。



2.局部视图中显示的数据应仅取决于局部视图使用的模型。局部视图使用其模型中的数据并在其内容中显示其中的一些(或全部)。



3.为了给你更多的建议你应该给关于你想做什么的更多细节,以及你上面问题中的代码!
1.In MVC you can use more partial views in the same view.

2.The data shown in the partial view should depend only on the Model that are used by the partial view. The partial view use the data from its Model and show some (or all) of them in their content.

3.In order to give you more advises you should give more details about what do you want to do and also about your code in your question above!


这篇关于如何在Mvc Razor视图中创建多个部分视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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