asp.net-mvc – 将参数传递给html partial并在部分html中检索值

前端之家收集整理的这篇文章主要介绍了asp.net-mvc – 将参数传递给html partial并在部分html中检索值前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
如何将参数传递给html partial并在部分html中检索值?
@Html.Partial(MVC.Cans.Shared.Views.Canviewmodels,Model,UserExists);

UserExists的逻辑是局部的,我不想为这个任务改变我的viewmodels.

你会如何解决这个问题?

@H_404_9@解决方法
您可以使用@ Html.Partial的第3个参数将其他视图数据传递给partial
@Html.RenderPartial("yourPartialName",yourModel,new ViewDataDictionary { { "userExists",true} });

您可以使用部分访问它

@ViewData["userExists"];
原文链接:https://www.f2er.com/aspnet/247393.html

猜你在找的asp.Net相关文章