Click here to Skip to main content
15,888,579 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have a hidden field in layout view(Main/parent view).I want to get the hidden field value in child view using mvc

I have no idea, how to get the value from parent view in child view.

Please help me to solve this issue.

Thanks

What I have tried:





  • @Html.ActionLink("Main", "Index", "Home")


  • @Html.ActionLink("Registration", "Index", "Registration")
  • @Html.ActionLink("Reports", "Index", "Report")

@if (User != null && !string.IsNullOrEmpty(User.Identity.Name))
{

@Html.Hidden("Role", (string)ViewBag.Role)
}
Posted
Updated 4-Feb-19 16:26pm

1 solution

In Right below of your child View:


$("#Role").val($("#Child").val())
 
Share this answer
 
Comments
priya9826 5-Feb-19 10:21am    
could you please send the sample layout and child view and where to write this code to get the value from parent view in child view?

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