如何使用html renderpartial创建自定义视图 [英] How can I use html renderpartial to create custom views

查看:130
本文介绍了如何使用html renderpartial创建自定义视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望创建常见的自定义局部视图。

我在多个页面中使用它作为底部菜单。选择某个页面时,会突出显示底部菜单中的相应选项卡。在我看来,renderpartial方法只有模型参数。我需要将自己的参数传递给renderpartial,例如string,int等...

有人能帮帮我吗?如果有一些有用的src或url,请注意我。

I hope create common custom partial view.
I use this for bottom menu in several pages. When certain page selected, corresponding tab in bottom menu is highlighted. In my opinion renderpartial method has only model parameter. I need pass my own parameter to renderpartial such as string, int, etc...
Could someone help me? If there are some useful src or url, then please notice me.

推荐答案

为什么不想将这些自定义变量放在模型中?

模特可以是你喜欢的任何颜色。



部分视图与普通视图完全相同,但它不包括布局。 br />
所以如果您知道如何在普通视图中执行此操作,您可以在部分视图中执行相同操作。
Why don't you want to put these custom variables in the model?
The model can be anything you like.

The partial view is exactly the same as a normal view, except it won't include the layout.
So If you know how to do it in a 'normal' view you can do the same in a partial.


这篇关于如何使用html renderpartial创建自定义视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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