Re: Access method in master's master

Tech-Archive recommends: Fix windows errors by optimizing your registry



...OK, have managed to work it out and at least I now understand what c# type
conversion looks like!

For anyone else who's interested the vb is as follows:
CType(Master.Master, ISetMenu).SetMenu("Products")

Thanks again Bruce. Works a treat.

Best regards

John


"John" <John74211@xxxxxxxxxxxxxxxx> wrote in message
news:OaOfFu4XIHA.3696@xxxxxxxxxxxxxxxxxxxxxxx
Hello Bruce,

I'm getting a bit further I think....

I've added the interface to app_code:

'Imports Microsoft.VisualBasic

Public Interface ISetMenu

Sub SetMenu(ByVal strMain As String)

End Interface


....and amended the MainMaster partial class, but I'm having difficulty
with the content page implementation.

You don't know what the VB.NET version of:

((ISetMenu) Master.Master).SetMenu("Products");

...would be do you? I'm afraid I'm new to c# and interfaces!

Thanks

John



"bruce barker" <brucebarker@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:F58B47C0-C3A9-4319-86DA-528FBABE4B71@xxxxxxxxxxxxxxxx
you should define an interface (in app_code) that the master implement,
then
your code can cast the Master to the interface:

in app_code:

public interface ISetMenu { void SetMenu(string name)}

then implement in your master:

public partial class MainMasterPage : System.Web.UI.MasterPage,
ISetMenu
{
}

then call:

((ISetMenu) Master.Master).SetMenu("Products");



-- bruce (sqlwork.com)


"John" wrote:

Hi there,

I'm trying to access a method in a nested master, so far without much
success.

The structure is as follows:

'Main master' (containing public menu setting method) is master to 'Sub
master', both of which are at the site root. The 'Sub master' is master
to
'Content page' in a folder.

Master.SetMenu("Products") - works if just used on a test content page
at
the root, but...
Master.Master.SetMenu("Products") - fails with an error saying 'SetMenu'
is
not a member of 'System.Web.UI.MasterPage'. I understand the error, but
how
can I access a method in a master's master?

Thanks

John

PS - I'm using <%@ MasterType VirtualPath="~/Sub.master" %> (and
"~/Main.master") in the respective masters.











.



Relevant Pages

  • Re: Access method in masters master
    ... Sub SetMenu ... .....and amended the MainMaster partial class, ... your code can cast the Master to the interface: ... public interface ISetMenu ...
    (microsoft.public.dotnet.framework.aspnet)
  • RE: Access method in masters master
    ... you should define an interface that the master implement, ... public interface ISetMenu ... Master.Master.SetMenu- fails with an error saying 'SetMenu' is ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Access method in masters master
    ... your code can cast the Master to the interface: ... public interface ISetMenu ... both of which are at the site root. ... The 'Sub master' is master ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: More than One
    ... affect the sub applications. ... In addition, for Master page, we can put different Master pages in ... referece Master pages in root application directory, ... Microsoft Online Support ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Handling events generated by a Master Page in a content placeh
    ... "Phillip Williams" escreveu na mensagem ... > Public Delegate Sub MasterPageEventHandler1(sender As Object, ... > Then In the content page you need to get a reference to the master page ... Event event1(ByVal sender As Object, ...
    (microsoft.public.dotnet.framework.aspnet)