How does MVC pass parameters to another view in the current view?

Source: Internet
Author: User

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?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.