Generally, in the MVC page, we use the ascx user control to write:
<% = Html. Partial ("adminviewleftmenu") %>
Or write as follows:
<% Html. renderpartial ("~ /Areas/util/views/shared/selectgroup. ascx "); %>
The difference between the above two reference methods:
Html. renderpartial is directly output to the current httpcontext, while HTML. Partial directly generates a string and returns the View content. Therefore, when referencing, the difference is <% html. renderpartial ("~ /Areas/util/views/shared/selectgroup. ascx "); %> and <% = html. Partial ("~ /Areas/util/views/shared/selectgroup. ascx "); %>.
When you need to add an action to the ascx user control, we need to reference it as follows:
<% Html. renderaction ("Index", "sectiongroup"); %>
The action is as follows:
Using System; Using System. Collections. Generic; Using System. LINQ; Using System. Web; Using System. Web. MVC; Namespace Educationmanage. Areas. util. controllers { Using Utility. JSON; Using Educationmanage. Areas. util. models; Public Class Sectiongroupcontroller: controller { // // Get:/util/sectiongroup/ Selectgroupentities = New Selectgroupentities (); Public Actionresult index () {list <Sg_admission_batchs> admissionbatchlist =Selectgroupentities. admission_batchs.tolist (); selectlist admissionbatch = New Selectlist (admissionbatchlist, " Admission_batch_id " , " Name " , "" ); Viewdata. Add ( " Admissionbatch " , Admissionbatch); List <Sg_education_levels> educationlevellist = Selectgroupentities. education_levels.tolist (); selectlist educationlevel = New Selectlist (educationlevellist, " Education_id " , " Name " , "" ); Viewdata. Add ( " Educationlevel " , Educationlevel); List <Sg_professional> professionallist = Selectgroupentities. Professional. tolist (); selectlist professional = New Selectlist (explorsionallist, " Prefessional_code " , " Name " , "" ); Viewdata. Add ( " Professional " , Professional ); ReturnPartialview ("~ /Areas/util/views/shared/sectiongroup. ascx" );}}}
For more information, seeArticle: Http://leelei.blog.51cto.com/856755/412702/