473,386 Members | 1,819 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Master pages

Adi
Hi all,

I have a menu which is placed in the master page. Now when the user
clicks on one of the menu item, it fires an event which is handled in
the master page. I need to know from which page the menu item was
clicked is there any way i can get the id of the page and verify it or
is there an alternate way to do it. I have recently started using
master pages in my website. previously I was having the menu control
in a web user control(.ascx), where i used to get the page id by using
Parent.Id.. in the master pages i get it as "__Page".

To be clear i have Banner.Master which has the menu control
i have the content page a.aspx and another content page b.aspx
when the user clicks on the menu item in page a.aspx then only it
should redirect it to b.aspx otherwise it shouldnt do anything.. or do
a simple post back.

i am using asp.net v2.0.

please let me know if you need further information.

thanks
Vijay

Sep 18 '07 #1
3 2697
You could access the page by doing the following.

Wire up the MenuItemClick event handler.

Like so: (this is in the master page's cs file)

protected void testMenu_MenuItemClick(object sender, MenuEventArgs e)
{
string pageName = (sender as
Menu).Page.AppRelativeVirtualPath;

// Display it to you as a js pop up

Page.ClientScript.RegisterClientScriptBlock(Page.G etType(),"alert",
string.Format("alert('Page: {0}');", pageName),true);
}

In the Master Page, you'd have this:

<asp:Menu runat="server" ID="testMenu"
OnMenuItemClick="testMenu_MenuItemClick">
<Items>
<asp:MenuItem Text="Link1" Value="1"></asp:MenuItem>
<asp:MenuItem Text="Link2" Value="=2"></asp:MenuItem>
</Items>
</asp:Menu>

I hope that helps you.

Sep 18 '07 #2
Why not use the URL of the Request? It will contain the Page file name.

--
HTH,

Kevin Spencer
Microsoft MVP

DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

"Adi" <gv*****@gmail.comwrote in message
news:11**********************@22g2000hsm.googlegro ups.com...
Hi all,

I have a menu which is placed in the master page. Now when the user
clicks on one of the menu item, it fires an event which is handled in
the master page. I need to know from which page the menu item was
clicked is there any way i can get the id of the page and verify it or
is there an alternate way to do it. I have recently started using
master pages in my website. previously I was having the menu control
in a web user control(.ascx), where i used to get the page id by using
Parent.Id.. in the master pages i get it as "__Page".

To be clear i have Banner.Master which has the menu control
i have the content page a.aspx and another content page b.aspx
when the user clicks on the menu item in page a.aspx then only it
should redirect it to b.aspx otherwise it shouldnt do anything.. or do
a simple post back.

i am using asp.net v2.0.

please let me know if you need further information.

thanks
Vijay

Sep 19 '07 #3
Adi
hey thanks guys.. tat helped me a lot..

Vijay

Sep 21 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Sasha | last post by:
Hi all asp.net proffesionals out there, How do you implement master pages in your applications? What libraries do you use and what have been your experience? Sasha
5
by: Michael Herman \(Parallelspace\) | last post by:
1. What are some compelling solutions for using Master/Content pages with Web Pages? 2. If a content area has a web part zone with web parts, what is the user experience like when "editting" the...
20
by: Alan Silver | last post by:
Hello, In classic ASP, I used to use two include files on each page, one before and one after the main content, to provide a consistent layout across a web site. That way I could just change the...
1
by: Alan Silver | last post by:
Hello, I am just experimenting with master pages, and am trying to add a content placeholder in the <head> section, so that individual pages can set their own page title and meta tags. The...
17
by: Rob R. Ainscough | last post by:
Again another simple concept that appears NOT to be intuitive or I'm just stupid. I've read the WROX book and the example doesn't actually show how the .master page links in the other content...
7
by: xkeops | last post by:
Thinking of creating a website, most of the pages will have a general toolbar menu, a content and a footer. The content will be the only one who's gonna change but the rest (header,footer) will...
8
by: JT | last post by:
Hi, I have done a fair amount of style editing inline in ASP. I'm now using VS 2005 with a standard web project (not Web Application Project). This is my first foray into CSS in a style sheet...
3
by: Rich | last post by:
Hi, I want to use 2 master pages, one for the main part of the site, the other for the admin pages. They are quite similar, with many shared elements. Ideally I would like to have a parent...
13
by: Kirk | last post by:
I have been reading Scott Allen's article on Master Pages (http:// odetocode.com/Articles/450.aspx) but I am having problems understanding a concept. Specifically, I have created a property...
6
by: Mickey | last post by:
Coming from a Dreamweaver/ASP/PHP background. Planning to use Visual Studio 2008 for a website. Complete newbie question here (please be gentle!): Do master pages work similar to Dreamweaver...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.