Differences between HTML. renderpartial and HTML. renderaction

Source: Internet
Author: User

Both html. renderpartial and HTML. renderactionp are used to embed the MVC user control into the view.

Html. renderpartial is to directly embed the MVC user control into the interface.

<% Html. renderpartial ("supplierlist"); %> note: the MVC user control must be placed in the same directory of the caller or in view/shared.

<% Html. renderpartial ("~ /Views/supplier/supplierlist. ascx "); %> specifies the directory of the MVC user control.

Html. renderaction calls the MVC user control through the action in the controller.

Added HTML in MVC 2.0. renderaction (); this method renderpartial is a bit different. He directly re-executes the order of controller → model → view, and then returns the generated page to the original view.

Therefore, the parameters passed in HTML. renderaction are the name of the controller and action to be executed. If a method in the controller can only be called by HTML. renderaction (), you can add the feature [childactiononly] to the method. The feature cannot be accessed elsewhere.

Public class childactiononlytestcontroller: Controller

{

[Childactiononly]

Public actionresult getsupplierlist ()

{

VaR controller = new suppliercontroller ();

Return controller. supplierlist ();

}

}

The following figure shows the execution process comparison.

Author: new bottle of old wine helps small and medium-sized enterprises grow and provides customized software development, implementation, and maintenance. It aims to explore the value of customers and help you achieve it. We look forward to cooperating with you!
Note: The copyright of this article belongs to the author. You are welcome to repost this article, but you must keep this statement without the author's consent andArticleThe original text connection is clearly displayed on the page. Otherwise, the legal liability is retained.

Logistics, goods distribution, freight transportation, websites, forums, exchanges, information publishing
Qq website construction: 471226865

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.