Here's the master:
<%@ Master Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Menu1_MenuItemClick(object sender, MenuEventArgs e)
{
Label mpLabel;
mpLabel= (Label)this.ContentPlaceHolder1.FindControl("Label 1");
if (mpLabel != null)
{
mpLabel.Text = Menu1.SelectedItem.Text;
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Menu Master</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:menu id="Menu1" runat="server" orientation="Horizontal"
onmenuitemclick="Menu1_MenuItemClick">
<items>
<asp:menuitem text="Colour" value="Colour">
<asp:menuitem text="Red" value="Red"></asp:menuitem>
<asp:menuitem text="Green" value="Green"></asp:menuitem>
<asp:menuitem text="Blue" value="Blue"></asp:menuitem>
</asp:menuitem>
<asp:menuitem text="Animal" value="Animal">
<asp:menuitem text="Dog" value="Dog"></asp:menuitem>
<asp:menuitem text="Cat" value="Cat"></asp:menuitem>
<asp:menuitem text="Pig" value="Pig"></asp:menuitem>
</asp:menuitem>
</items>
</asp:menu>
</div>
<asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
</asp:contentplaceholder>
</form>
</body>
</html>
Here's the page:
<%@ Page Language="C#" MasterPageFile="~/menu.master" Title="Catch Menu" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">
<br />
<asp:label id="Label1" runat="server" text="Label"></asp:label>
</asp:Content>
When the menu is selected. it finds the contentplaceholder and the label and
sets the text.
Okay?
Ken
"Joao Batista" <teste@iol,pt> wrote in message
news:OM**************@TK2MSFTNGP10.phx.gbl...
Hi Ken,
i'm a newbie here, I know that (and i can get the reference to the menu),
but i don't know how to get reference to the selected item, have you some
example where i can see that.
Thank's
Joao Batista
"Ken Cox - Microsoft MVP" <BA**********@hotmail.com> escreveu na mensagem
news:%2******************@tk2msftngp13.phx.gbl... Hi Joao,
You need to get a reference to the master page using FindControl and with
that, get a reference to the menu. The menu reference should give you its
select item name or id.
Here's where to start:
http://msdn2.microsoft.com/en-us/lib...f0(VS.80).aspx
Ken
Microsoft MVP [ASP.NET]
"Joao Batista" <teste@iol,pt> wrote in message
news:uP**************@TK2MSFTNGP10.phx.gbl... Hi all,
I have a MasterPage with a menu, populated from a database, my problem
now is when i chose an option , how can i pass (catch) the value to my
products page???
Thanks
Joao Batista