Html.RenderControl

Modified on 2012/06/27 21:33 by Administrator — Categorized as: MWSF

Description

Html.RenderControl good for pages' splitting up or anything you want to separate like include in asp

Bonghwa tour -> main page - but it is used inside MainWidgets.cs main-page - also used inside MainWidgets.cs

if you check http://ycg.kr/open.content/ko/administrative/policy/

you can see inside default.aspx such things

<%:Html.RenderControl("test.ascx")%>

inside test.ascx you put html and init function

http://ycg.kr/open.content/ko/weather.ascx for example like include in asp

but you also can write Init() function if you have dynamic html, like in case of weather.ascx

<script runat="server">
void Init()
{
//blah-blah-blah
}
</script>

like Page_Load

Class


Public Methods

<%:Html.RenderControl("test.ascx")%>

need test.ascx file in same folder

test.ascx example
<ul>
	<li>test</li>
	<li>test2</li>
</ul>

Example

default.aspx 와 *.ascx가 같은 폴더에 있을때

Default.aspx

<%:Html.RenderControl("test.ascx")%>
<%:Html.RenderControl("test2.ascx")%>

test.ascx

<ul>
	<li>test</li>
	<li>test2</li>
</ul>

test2.ascx

<div>new test</div>

<script runat="server">
dynamic weather;
void Init()
{
   ......content ....
}
</script>

default.aspx와 common.ascx가 다른 폴더에 있을때

Default.aspx

<%@ Page Inherits="SubPage" %>

<asp:Content ContentPlaceHolderID="contentMain" runat="server">
<%:Html.RenderControl("common.ascx", searchParent: true)%>
</asp:Content>

다른폴더에 있는 common.ascx

<%@Import Namespace="kr.or.must.mwsf" %>

<%:Html.CreateSubMenu(3, new { @class = "tab-menu" }) %>
<%:Html.CreateSubMenu(new { @class = "sub-menu" }) %>
<div class="first-map">
	<%:Html.Image(MenuController.GetMenu("common"), "map1f.png", "자연생태전시관 1층 위치도", "map")%>
	<p><a href="#" title="VR보기"><%:Html.Image(MenuController.GetMenu("common"), "vr-btn-etc.png", "VR보기", "")%></a></p>
</div>