简体   繁体   English

如何在加载时将值从父视图传递到部分视图

[英]How to pass value from Parent View to Partial View on load

I am opening one edit Profile page in my view. 我在视图中打开一个编辑配置文件页面。 I want to display skills of the person in his profile Page; 我想在他的个人资料页面上显示该人的技能; his skills are stored in another table. 他的技能存储在另一个表中。 Now I want to open one Partial View to show his skills. 现在,我想打开一个局部视图以展示他的技能。 Please help me how to show the partial View. 请帮助我如何显示局部视图。

Thanks in advance. 提前致谢。

If I am not wrong in understanding your question, then I think you just to use 如果我在理解您的问题时没有错,那么我认为您只是在使用

    @Html.Action("Skills","Profile", new { id = 1 })

where "Profile" is your controller and "Skills" is your action. 其中“个人资料”是您的控制者,“技能”是您的操作。

You can get skills for profile by passing ID of profile to that action and from that action you can use 您可以通过将个人资料ID传递给该动作来获取个人资料技能,然后从该动作中使用

    return Partial(model);

这个问题很模糊,但是假设您有一个在父视图中声明的模型带有一个称为Skills的属性,那么您可以将内容传递给部分视图,如下所示:

@{ Html.RenderPartial("SkillsForm", Model.Skills); }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM