哪个子页面加载了MasterPage? [英] Which sub-page load the MasterPage ??

查看:105
本文介绍了哪个子页面加载了MasterPage?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在制作ASP.net网站,并且在项目中有MasterPage,
有很多页面具有此MasterPage,例如:
关于页面,主页……等.

我想在 MasterPage的Load事件 中编写代码,以了解现在正在加载MasterPage的页面,就像该代码一样:

如果(关于页面)
//这里的任何代码
否则,如果(主页)
//这里的任何代码

希望你能理解我

谢谢

Hi every body,

I am making ASP.net website and i have MasterPage in the project,
there are many page has this MasterPage like:
About page, home page, ...... ect.

I want to write code in the Load event of MasterPage to know which page is load the MasterPage now, as like that code:

if (About page)
// any code here
else if (Home page)
// any code here

I hope you understand me

Thanks

推荐答案

尝试这个

try this

string currentPage = Request.Url.ToString().ToLower();
        if (currentPage.Contains("about.aspx"))
        {
            //do your thing here
        }
        else if (currentPage.Contains("home.aspx"))
        {
            //do your thing here
        }
        else
        {
        }


这篇关于哪个子页面加载了MasterPage?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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