How does mvc pass Parameters to another view in the current view ?, Mvc View

Source: Internet
Author: User

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 ");

 

Related Article

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.