Re: Access method in master's master
- From: "John" <John74211@xxxxxxxxxxxxxxxx>
- Date: Sat, 26 Jan 2008 15:29:43 -0000
...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.
.
- References:
- Access method in master's master
- From: John
- RE: Access method in master's master
- From: bruce barker
- Re: Access method in master's master
- From: John
- Access method in master's master
- Prev by Date: Re: odbc connection
- Next by Date: Re: Using IIS w/ASP .NET 2.0 Web Application Projects
- Previous by thread: Re: Access method in master's master
- Next by thread: configuration tool
- Index(es):
Relevant Pages
|