Click here to Skip to main content
15,113,057 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
public ActionResult TaskDetails(string id)
    if (ViewBag.Title == "ProjectApproval")
        //do something
Updated 12-Oct-14 23:00pm
[no name] 13-Oct-14 1:43am
show your action result code and partial view code

1 solution

It should work without any problem. Check this link[^] for more information
Mohammad A. Amer 13-Oct-14 4:10am
Thanks for your quick response but I want to do the reverse by setting the viewbag in the partial view and check its value in the action result.
Or by other meaning I want to check the title of the partial view in my action result.
Venkatesh Mookkan 13-Oct-14 17:59pm
Try using ViewData

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900