Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / September 2007

Tip: Looking for answers? Try searching our database.

Master pages

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Adi - 18 Sep 2007 22:52 GMT
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
Donn Felker - 18 Sep 2007 23:56 GMT
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.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_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.
Adi - 21 Sep 2007 14:29 GMT
hey thanks guys.. tat helped me a lot..

Vijay
Kevin Spencer - 19 Sep 2007 14:07 GMT
Why not use the URL of the Request? It will contain the Page file name.

Signature

HTH,

Kevin Spencer
Microsoft MVP

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

> Hi all,
>
[quoted text clipped - 19 lines]
> thanks
> Vijay

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.