Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Calling MasterPage Subroutines from a ContentPage

Reply
Thread Tools

Calling MasterPage Subroutines from a ContentPage

 
 
jeffmagill@gmail.com
Guest
Posts: n/a
 
      06-20-2006
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

 
Reply With Quote
 
 
 
 
=?Utf-8?B?TWFya0F1cml0?=
Guest
Posts: n/a
 
      06-20-2006
In your aspx add:
<%@ MasterType virtualPath="~/<MasterPageName>.master"%>

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

Hope this is what you needed.

"(E-Mail Removed)" 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
>
>

 
Reply With Quote
 
 
 
 
Tod Birdsall, MCSD for .NET
Guest
Posts: n/a
 
      06-20-2006
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.
>
> "(E-Mail Removed)" 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
> >
> >


 
Reply With Quote
 
jeffmagill@gmail.com
Guest
Posts: n/a
 
      06-20-2006
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.
> >
> > "(E-Mail Removed)" 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
> > >
> > >


 
Reply With Quote
 
clintonG
Guest
Posts: n/a
 
      06-21-2006
You'll be back

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

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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.
>> >
>> > "(E-Mail Removed)" 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
>> > >
>> > >

>



 
Reply With Quote
 
jeffmagill@gmail.com
Guest
Posts: n/a
 
      06-21-2006
It worked prefectly. Thank you so much guys!

 
Reply With Quote
 
TuckWong TuckWong is offline
Junior Member
Join Date: Jan 2013
Posts: 2
 
      01-11-2013
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.

 
Reply With Quote
 
TuckWong TuckWong is offline
Junior Member
Join Date: Jan 2013
Posts: 2
 
      01-11-2013
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Finding Value of Dynamic Control in MasterPage/ContentPage System dawg1998 ASP .Net 2 05-31-2010 06:19 AM
GetElementbyID question - within MasterPage/contentpage - within tables Elmo Watson ASP .Net 1 05-08-2007 05:12 PM
Finding Value of Dynamic Control in MasterPage/ContentPage System =?Utf-8?B?ZGF3ZzE5OTg=?= ASP .Net 0 03-15-2006 05:26 PM
MasterPage Method Invocation from ContentPage User ASP .Net 9 12-19-2005 11:20 AM
Change Webcontrols from a Contentpage in the Masterpage phil1bruening@web.de ASP .Net 1 11-22-2005 03:39 PM



Advertisments