M
Michael Richter
hi, all,
I'm a desperately seeking (MS search, google ...) for a solution in
referencing a menu control that is placed on a master page from a content
page.
Let me show you what I have got (VS 2005, VB.NET only):
* MasterPage:
1 <asp:Menu ID="KostenMenu" Enabled="true" EnableViewState="true"
runat="server" Orientation="Vertical" Visible="False"
DynamicEnableDefaultPopOutImage="False"
StaticEnableDefaultPopOutImage="False" CssClass="Menu">
2 <Items> ... </Items>
3 </asp:Menu>
[...]
10 <asp:ContentPlaceHolder ID="ContentPlaceHolderPSP" runat="server">
11 </asp:ContentPlaceHolder>
--- end master page ---
* Content Page:
* aspx file:
1 <%@ Page Language="VB" MasterPageFile="~/MasterPSP.master"
AutoEventWireup="false"
CodeFile="[FileName].aspx.vb" Inherits="[Name of aspx file]"
Title="[...]" %>
2 <%@ MasterType VirtualPath="~/MasterPSP.master" %>
[...]
* aspx.vb file (code behind/beside):
1 Private Sub InitializePage()
2 'delegate from master
3 Dim KostenMenuA As Menu
4 Dim KostenMenu_ItemClick As EventHandler
5 KostenMenuA = New Master.FindControl("KostenMenu")
6 AddHandler KostenMenu_ItemClick, New KostenMenuA.MenuItemClick()
[...]
10 End Sub
[...]
100 Protected Sub KostenMenu_ItemClicked(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.MenuEventArgs) Handles KostenMenu_ItemClick()
[things to do]
110 End Sub
--- end content page ---
As you might have experienced once Visual Studio claims "Type
'Master.FindControl' is not defined" in line 5 of aspx.vb file. which I
cannot understand really. (Perhaps I'm just hung up in the circle of my on
thinking about that problem). All samples I found on the net make use of the
above syntax and seem working but not on my system :-(( .
Ok, if one has a heart for a .Net newbie like me, please help.
Thanks in advance,
michael
I'm a desperately seeking (MS search, google ...) for a solution in
referencing a menu control that is placed on a master page from a content
page.
Let me show you what I have got (VS 2005, VB.NET only):
* MasterPage:
1 <asp:Menu ID="KostenMenu" Enabled="true" EnableViewState="true"
runat="server" Orientation="Vertical" Visible="False"
DynamicEnableDefaultPopOutImage="False"
StaticEnableDefaultPopOutImage="False" CssClass="Menu">
2 <Items> ... </Items>
3 </asp:Menu>
[...]
10 <asp:ContentPlaceHolder ID="ContentPlaceHolderPSP" runat="server">
11 </asp:ContentPlaceHolder>
--- end master page ---
* Content Page:
* aspx file:
1 <%@ Page Language="VB" MasterPageFile="~/MasterPSP.master"
AutoEventWireup="false"
CodeFile="[FileName].aspx.vb" Inherits="[Name of aspx file]"
Title="[...]" %>
2 <%@ MasterType VirtualPath="~/MasterPSP.master" %>
[...]
* aspx.vb file (code behind/beside):
1 Private Sub InitializePage()
2 'delegate from master
3 Dim KostenMenuA As Menu
4 Dim KostenMenu_ItemClick As EventHandler
5 KostenMenuA = New Master.FindControl("KostenMenu")
6 AddHandler KostenMenu_ItemClick, New KostenMenuA.MenuItemClick()
[...]
10 End Sub
[...]
100 Protected Sub KostenMenu_ItemClicked(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.MenuEventArgs) Handles KostenMenu_ItemClick()
[things to do]
110 End Sub
--- end content page ---
As you might have experienced once Visual Studio claims "Type
'Master.FindControl' is not defined" in line 5 of aspx.vb file. which I
cannot understand really. (Perhaps I'm just hung up in the circle of my on
thinking about that problem). All samples I found on the net make use of the
above syntax and seem working but not on my system :-(( .
Ok, if one has a heart for a .Net newbie like me, please help.
Thanks in advance,
michael