首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

哪位高手提供一个代码分离的动态加载MasterPage的例子

2012-01-10 
谁提供一个代码分离的动态加载MasterPage的例子!例如有一个页面default.aspx和两个模版MasterA.master,Mas

谁提供一个代码分离的动态加载MasterPage的例子!
例如有一个页面default.aspx
和两个模版MasterA.master,MasterB.master
现要求一:前后台代码分离
二:先调用MasterA.master
三:点击按钮后,调用MasterB.master


[解决办法]
打电话我告诉你
[解决办法]
masterpage A:
<%@ Master Language= "C# " %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">

<script runat= "server ">

</script>

<html xmlns= "http://www.w3.org/1999/xhtml " >
<head runat= "server ">
<title> Untitled Page </title>
</head>
<body>
<form id= "form1 " runat= "server ">
<div>
<asp:ContentPlaceHolder ID= "cp_Head " runat= "server ">
masterpage A
</asp:ContentPlaceHolder>
<asp:contentplaceholder id= "ContentPlaceHolder1 " runat= "server ">
</asp:contentplaceholder>
</div>
</form>
</body>
</html>


masterpage B:
<%@ Master Language= "C# " %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">

<script runat= "server ">

</script>

<html xmlns= "http://www.w3.org/1999/xhtml " >
<head id= "Head1 " runat= "server ">
<title> Untitled Page </title>
</head>
<body>
<form id= "form1 " runat= "server ">
<div>
<asp:ContentPlaceHolder ID= "cp_Head " runat= "server ">
masterpage B
</asp:ContentPlaceHolder>
<asp:contentplaceholder id= "ContentPlaceHolder1 " runat= "server ">
</asp:contentplaceholder>
</div>
</form>
</body>
</html>


[解决办法]
protected void BtnKick_Click(object sender, EventArgs e)
{
If(Page.MasterPageFile == "MasterB.master ")
{
Page.MasterPageFile== "MasterA.master ";
}
Else
{
Page.MasterPageFile== "MasterB.master ";
}

}

热点排行