How does mvc pass Parameters to another view in the current view ?, Mvc View
In the TransData. cshtml View:
<Div>
<! -- In one view, request another view and upload data to another view -->
<! -- To call a method without a return value in the view, braces must be added -->
@ {ViewBag. ViewTransData = "I am the data defined in the 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 ";
}
<H2> LoadViewBySelf @ ViewBag. ViewTransDataTTT
@ ViewData ["ViewTransDataTTT"]
Run the TransData view to obtain the following information:
:
View the source file:
You do not need to add braces when calling the method with a return value in the view;
@ {Html. RenderPartial ("LoadViewBySelf") ;}<! -- Call the method with a return value in the view without increasing the brackets --> @ Html. TextBox ("testname ");