以编程方式设置母版页 [英] Setting Master Page Programmatically

查看:100
本文介绍了以编程方式设置母版页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好
我在我的应用程序中生成了一些aspx(Web内容页面).我的母版页位于应用程序"根目录下,但那些内容页面在目录"root/pages/page1/"中创建.现在,我必须将母版页设置为这些内容页.这样,我尝试设置母版页,并在生成时在aspx页中添加了这些代码.

Hi all
I a generating some aspx (web content page) in my application. My master page is at the Application root but those content pages are creating in the Directory "root/pages/page1/". Now I have to set the master page to these content page. In this way I tried to set the master page and added these codes in the aspx page when it was generating.

<script runat="Server">
    Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit
         Me.MasterPageFile = &quot;../../Main.master&quot;
    End Sub
</script>


但母版页无法关联.任何人都可以帮我吗.
谢谢,


but the master page could not associate. Can any body help me please.
Thanks,

推荐答案

查看此链接,阅读完整的文章.

http://www.asp.net/master-pages/tutorials/以编程方式指定主页面" [ ^ ]
Look at this link and read the ENTIRE article.

http://www.asp.net/master-pages/tutorials/specifying-the-master-page-programmatically-vb[^]


这篇关于以编程方式设置母版页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆