Click here to Skip to main content
15,899,314 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Updated 31-Oct-10 16:22pm
v2

1 solution

try this

C#
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
        {
        }
 
Share this answer
 
v2
Comments
MrLonely_2 31-Oct-10 23:28pm    
Thanks very much for you.
I also found that:
string currentPage = HttpContext.Current.Request.Url.AbsolutePath;

Thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900