473,804 Members | 3,174 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2751
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_MenuIt emClick(object sender, MenuEventArgs e)
{
string pageName = (sender as
Menu).Page.AppR elativeVirtualP ath;

// Display it to you as a js pop up

Page.ClientScri pt.RegisterClie ntScriptBlock(P age.GetType()," alert",
string.Format(" alert('Page: {0}');", pageName),true) ;
}

In the Master Page, you'd have this:

<asp:Menu runat="server" ID="testMenu"
OnMenuItemClick ="testMenu_Menu ItemClick">
<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.goog legroups.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
1628
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
2444
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 web part page? Does it take place at the page level? ...or the content area level? 3. Where is the Web Part Manager instantiated? ...in the Master Page? ....Content Page? ...elsewhere?
20
2429
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 include files to change the layout. When I came to ASP.NET, I used user controls to do a similar thing. I have just been looking at master pages, and it looks like they do the same thing. If so, is there any advantage in using them over the...
1
1875
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 master page looks like this... <%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
17
3165
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 pages? Kinda sorta a critical point no? Am I missing something? Rob. P.S. the day I find a book that actually is useful rather than just a
7
8733
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 remain the same. I am interested to know your opinions/suggestions in finding an easy way of doing it. In asp one could have something like this:
8
6703
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 and also my first true attempt at using master pages. I tried setting up a style sheet with a simple setting to float an image to the right and it had no effect on the image. Then, I tried putting the style code in my ASPX file as such,
3
5977
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 master page, which both of these child master pages are based on, and in turn the final pages are based on one of these child master pages.
13
5318
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 (called "CurFlag") on my master page that can be accessed from content pages, but not from separate code modules. I tried doing something like this in my VB code module: Dim myMaster As MasterPage = CType(ProjectMgmt.Master, MasterPage)
6
1692
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 templates in that when the master page is updated, all the child pages created from the master page are updated and then they all need to be uploaded to the server? Or do you only have to upload the master page after an update?
0
9706
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10577
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10077
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9150
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6853
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4299
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3820
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2991
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.