Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   Calling MasterPage Subroutines from a ContentPage (http://www.velocityreviews.com/forums/t300574-calling-masterpage-subroutines-from-a-contentpage.html)

jeffmagill@gmail.com 06-20-2006 09:00 PM

Calling MasterPage Subroutines from a ContentPage
 
Is it possible? I haven't been able to find any information about this.
Not on the web, not in books.

Is it possible to call a function or subroutine which is defined in a
MasterPage from it's derivative ContentPage?

Thanks.
Jeff


=?Utf-8?B?TWFya0F1cml0?= 06-20-2006 09:45 PM

RE: Calling MasterPage Subroutines from a ContentPage
 
In your aspx add:
<%@ MasterType virtualPath="~/<MasterPageName>.master"%>

Then in its codebehind:
this.Master.MyMethod()

Hope this is what you needed.

"jeffmagill@gmail.com" wrote:

> Is it possible? I haven't been able to find any information about this.
> Not on the web, not in books.
>
> Is it possible to call a function or subroutine which is defined in a
> MasterPage from it's derivative ContentPage?
>
> Thanks.
> Jeff
>
>


Tod Birdsall, MCSD for .NET 06-20-2006 09:59 PM

Re: Calling MasterPage Subroutines from a ContentPage
 
Hi Mark,

Thanks for pointing this out. K. Scott Allen has a more detailed, but
in VB.NET, article here:

http://odetocode.com/Blogs/scott/arc...7/16/1944.aspx

Tod Birdsall, MCSD for .NET
software blog: http://tod1d.net


MarkAurit wrote:
> In your aspx add:
> <%@ MasterType virtualPath="~/<MasterPageName>.master"%>
>
> Then in its codebehind:
> this.Master.MyMethod()
>
> Hope this is what you needed.
>
> "jeffmagill@gmail.com" wrote:
>
> > Is it possible? I haven't been able to find any information about this.
> > Not on the web, not in books.
> >
> > Is it possible to call a function or subroutine which is defined in a
> > MasterPage from it's derivative ContentPage?
> >
> > Thanks.
> > Jeff
> >
> >



jeffmagill@gmail.com 06-20-2006 10:52 PM

Re: Calling MasterPage Subroutines from a ContentPage
 
Thanks for your quick responses!! I'll let you guys know how it turns
out.

You're welcome for point this out. If you want, I can point out more
problems sooner :)

Jeff

Tod Birdsall, MCSD for .NET wrote:
> Hi Mark,
>
> Thanks for pointing this out. K. Scott Allen has a more detailed, but
> in VB.NET, article here:
>
> http://odetocode.com/Blogs/scott/arc...7/16/1944.aspx
>
> Tod Birdsall, MCSD for .NET
> software blog: http://tod1d.net
>
>
> MarkAurit wrote:
> > In your aspx add:
> > <%@ MasterType virtualPath="~/<MasterPageName>.master"%>
> >
> > Then in its codebehind:
> > this.Master.MyMethod()
> >
> > Hope this is what you needed.
> >
> > "jeffmagill@gmail.com" wrote:
> >
> > > Is it possible? I haven't been able to find any information about this.
> > > Not on the web, not in books.
> > >
> > > Is it possible to call a function or subroutine which is defined in a
> > > MasterPage from it's derivative ContentPage?
> > >
> > > Thanks.
> > > Jeff
> > >
> > >



clintonG 06-21-2006 03:09 AM

Re: Calling MasterPage Subroutines from a ContentPage
 
You'll be back ;-)

<%= Clinton Gallagher
NET csgallagher AT metromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/

<jeffmagill@gmail.com> wrote in message
news:1150843947.823346.118240@b68g2000cwa.googlegr oups.com...
> Thanks for your quick responses!! I'll let you guys know how it turns
> out.
>
> You're welcome for point this out. If you want, I can point out more
> problems sooner :)
>
> Jeff
>
> Tod Birdsall, MCSD for .NET wrote:
>> Hi Mark,
>>
>> Thanks for pointing this out. K. Scott Allen has a more detailed, but
>> in VB.NET, article here:
>>
>> http://odetocode.com/Blogs/scott/arc...7/16/1944.aspx
>>
>> Tod Birdsall, MCSD for .NET
>> software blog: http://tod1d.net
>>
>>
>> MarkAurit wrote:
>> > In your aspx add:
>> > <%@ MasterType virtualPath="~/<MasterPageName>.master"%>
>> >
>> > Then in its codebehind:
>> > this.Master.MyMethod()
>> >
>> > Hope this is what you needed.
>> >
>> > "jeffmagill@gmail.com" wrote:
>> >
>> > > Is it possible? I haven't been able to find any information about
>> > > this.
>> > > Not on the web, not in books.
>> > >
>> > > Is it possible to call a function or subroutine which is defined in a
>> > > MasterPage from it's derivative ContentPage?
>> > >
>> > > Thanks.
>> > > Jeff
>> > >
>> > >

>




jeffmagill@gmail.com 06-21-2006 05:54 PM

Re: Calling MasterPage Subroutines from a ContentPage
 
It worked prefectly. Thank you so much guys!


TuckWong 01-11-2013 03:47 AM

I HOPE MY SOLUTION HELPS MANY SEEKING ANSWERS LIKE MYSELF BUT FAILED.
(1) One thing you guys left out in contentpage calling masterpage.
In ContentPage aspx, you cannot add this
<%
@MasterTypevirtualpath="~/{Your Masterpage}.Master" %>
When compile, you get compiler error
So, dont add!
(2) Calling a Public Routine (Property or Function) that is in Masterpage
In Content Page:
just write code as
CType
(Master, {Your MasterPage Name}).{Your MasterPage.PublicRoutine)

That's all. However, do note that inside masterpage page_load,what you declared here will return empty in your calling.


TuckWong 01-11-2013 03:54 AM

IN ADDITION TO MY COMMENTS:
(1)When contentpage is called, masterpage will load next. So....
In ContentPage Page_load, When you reference a masterpage routine, you may get empty result because the Masterpage.pageload is loaded second.
Hence, whatever variables you assigned value is not captured yet.

Again, just write as:
Dim a as string
a = CType(Master, {Your MasterPage Name}).{Your MasterPage.PublicRoutine)

Hope I helped someone.

Cheers,
Tuck
june1629 at yahoo dot come


All times are GMT. The time now is 05:15 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.