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