如何获得“ViewBag.Title”我对控制器的局部视图? [英] How do I get the "ViewBag.Title" of my partial view to a controller?
本文介绍了如何获得“ViewBag.Title”我对控制器的局部视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
由于我有多个局部视图,我想在控制器中使用视图标题名称。
我如何获得ViewBag.Title我对控制器的局部视图?
我的部分视图类似于
As I have more than one partial view and I want to use the view title name in the controller.
How do I get the "ViewBag.Title" of my partial view to a controller?
my partial view something like
@{
ViewBag.Title = "ProjectApproval";
}
我的行动结果
my action result
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult TaskDetails(string id)
{
if (ViewBag.Title == "ProjectApproval")
{
//do something
}
}
推荐答案
它应该没有任何工作问题。请查看此链接 [ ^ ]了解更多信息
It should work without any problem. Check this link[^] for more information
这篇关于如何获得“ViewBag.Title”我对控制器的局部视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文