I have a master page with a control on it, but I need to set a property of
that control from the content.
my master page is called Admin.Master and the class is Admin.
I have tried this
dim mp as Admin
mp = Ctype(me.master, Admin)
But I get the error that ASP.Master_Admin cannot be converted to Admin
How can I do this ?
Thanks
((ControlType)Page.Master.Controls[0].FindControl("<the_control>")).PropertyToSet
= "" ;
If you go route its better to write it as..
ControlType myControl =
(ControlType)Page.Master.Controls[0].FindControl("<control_id>");
if (myControl != null) {
myControl.Property = "blah";
I see your point, but It should be possible to do this I have written a
function in the master page which sets the user control property.
Now all I need to do is to be able to call the function on the master page.
In design time, the page.master property does not return the 'Type' of the
master page as they of course are potentially different.
In which case I need to cast the returned type so I can make a call to this
function.
"aWilson" <a.wil...@gmail.com> wrote in message
news:1171995943.8...@k78g2000cwa.googlegroups.com...
I'm a little confused at what you're needing, but you should be able
to reference a property
on the master page by doing the following:
((<your master page name>)Master).<master page property name> =
<some value>
or
<some local variable> = ((<your master page name>)Master).<master
page property name>
Also to keep in mind is the sequence in which the events fire.
Public Sub UserDisplayMessage(ByVal message As String, ByVal UserMessageType
As ScreenMessageType)
Me.AdminHeader1.UserDisplayMessage(message, UserMessageType)
End Sub
From the webcontent page, Ineed to reference it, but it does not appear Me.
. . . .
"bpd" <bryan...@rollcoater.com> wrote in message
news:1171999022.7...@v33g2000cwv.googlegroups.com...
On Feb 20, 1:32 pm, "Just Me" <news.microsoft.com> wrote:
> Hi
>
> I see your point, but It should be possible to do this I have written a
> function in the master page which sets the user control property.
>
> Now all I need to do is to be able to call the function on the master
> page.
> In design time, the page.master property does not return the 'Type' of the
> master page as they of course are potentially different.
>
> In which case I need to cast the returned type so I can make a call to
> this
> function.
>
> "aWilson" <a.wilso...@gmail.com> wrote in message
>
> news:1171995943.8...@k78g2000cwa.googlegroups.com...
>
>
>
> > You should be able to access the master page control via Page.Master.
> > The below is an example in c#.
>
> > ((ControlType)Page.Master.Controls[0].FindControl("<the_control>")).Propert軌ToSet
> From the webcontent page, Ineed to reference it, but it does not appear
> Me.
Have you forgotten to add the MasterType directive...?
http://www.codeproject.com/aspnet/InsideMasterPages.asp
Sorry to say that but you should not do that. If internal implementation
details change in future you will instroduce a bug (i.e, they wrap it with
another container)It's better to expose a property from master page and cast
Master property of the content page to actuall master page type (or use
@MasterType page directive). In addition findcontrol approach is not
supported by compiler, and in case you change / remove / delete the controls
it's more likely you forget about the FindControl() code and will introduce a
bug. Whilst second approach in this case would generate a compiler error.
Regards
--
Milosz
1.) A function in the masters user control.
2.) A function in the master to set the user control
3.) A manully inserted function to call the master function in each page
derived from it.
Kinda makes things overly complicated.
I wonder if master pages are actually worth it, when you can acheive similar
results from using user controls without all the agravation. This also
includes of course the fact all controls on the loose there primitive ID so
style sheets become a pain,
"Mark Rae" <ma...@markNOSPAMrae.com> wrote in message
news:u7%233QJTV...@TK2MSFTNGP03.phx.gbl...