Data interaction between view and control

Source: Internet
Author: User

Data interaction between view and control

1.viewbag.name = "Name1"

2.viewdata["VD" = "View data";

3.tempdata["TD"] = "temp data";

4.Model

ViewBag and ViewData are valid only in the current action, with the same life cycle and View;

TempData can continue to be used by steering because its value is stored in the session. However, TempData can only be passed once and then automatically cleared by the system.

text messages such as generic strings can be passed through viewbag, if the background needs to pass multiple entities, one way is to encapsulate multiple entities into one entity and then transfer them, and the other is to place some entities in some view

5. Set the object to public in C and the view can be accessed (not recommended)

6. In the view inside the Viewbag.title definition to obtain data (equivalent to the background), and then access to the page (equivalent to ASP mode)

Return JSON

Jsonresult

Json (New {success = true, message = "Comment Saved! ", jsonrequestbehavior.allowget});

Data interaction between view and control

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.