In the transdata.cshtml view:
<div>
<!--in one view, request another view, and upload the data to another view --
< call a method with no return value in!--view, you need braces--
@{viewbag.viewtransdata= "I am the data defined in view Transdata and will be passed to the Loadviewbyself view";
@{html.renderpartial ("Loadviewbyself");}
</div>
Request the Loadviewbyself view and pass the data to it:
@{
Viewbag.title = "Loadviewbyself";
}
@ViewBag. viewtransdatattt
@ViewData ["VIEWTRANSDATATTT"]
Then run the Transdata view to get:
:
View the source file to see:
A method that has a return value is called in the view, and no braces are added;
@{html.renderpartial ("loadviewbyself");} <!--call a method with a return value in the view without increasing the parentheses-to- @Html. TextBox ("testname");
How does MVC pass parameters to another view in the current view?