473,396 Members | 2,082 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Accessing method in master page from content page

OK, now I'm getting excited. I actually created a master page and added two
content place holders to it. I also added a label which will serve as a sort
of one line help and a little image button beside it to turn off the help.

I wrote a public method in the master page that looks like this:

public void tattle(string as_msg)
{
microhelp.Text = as_msg;
}

Pretty simple. microhelp is that label that I spoke of. How can I run the
tattle method from a content page?

--
----------------------------------------
Magic is not in the hands of the magician but in the mind of the audience.

Animadverto est verus
Dec 22 '05 #1
4 1931
Rik,

You can get the MasterPage instance from the Master property on your
page. Once you have that, you should be able to cast that to an instance of
your specific page type, and call the method.

However, I would say that doing this doesn't make sense. If anything,
you should have your master page implement an interface and then cast the
value of Master to that interface.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Rik Brooks" <rb*****@hhcc.com.donotspam> wrote in message
news:F7**********************************@microsof t.com...
OK, now I'm getting excited. I actually created a master page and added
two
content place holders to it. I also added a label which will serve as a
sort
of one line help and a little image button beside it to turn off the help.

I wrote a public method in the master page that looks like this:

public void tattle(string as_msg)
{
microhelp.Text = as_msg;
}

Pretty simple. microhelp is that label that I spoke of. How can I run the
tattle method from a content page?

--
----------------------------------------
Magic is not in the hands of the magician but in the mind of the audience.

Animadverto est verus

Dec 22 '05 #2
Thank you so much Nicholas, but that confused me more than ever. First of
all, I've implemented interfaces in classes in Java, but didn't know that you
could do that for an asp page.

Secondly, I really don't understand what you mean with your instructions.
Could I prevail upon you to give me a couple of lines as an example --- if I
ask, pretty please?
----------------------------------------
Magic is not in the hands of the magician but in the mind of the audience.

Animadverto est verus


"Nicholas Paldino [.NET/C# MVP]" wrote:
Rik,

You can get the MasterPage instance from the Master property on your
page. Once you have that, you should be able to cast that to an instance of
your specific page type, and call the method.

However, I would say that doing this doesn't make sense. If anything,
you should have your master page implement an interface and then cast the
value of Master to that interface.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Rik Brooks" <rb*****@hhcc.com.donotspam> wrote in message
news:F7**********************************@microsof t.com...
OK, now I'm getting excited. I actually created a master page and added
two
content place holders to it. I also added a label which will serve as a
sort
of one line help and a little image button beside it to turn off the help.

I wrote a public method in the master page that looks like this:

public void tattle(string as_msg)
{
microhelp.Text = as_msg;
}

Pretty simple. microhelp is that label that I spoke of. How can I run the
tattle method from a content page?

--
----------------------------------------
Magic is not in the hands of the magician but in the mind of the audience.

Animadverto est verus


Dec 22 '05 #3
Rik,

Say tattle is implemented as you have it, in your master page class,
called MyMasterPage. In your page that has the content, you would do
something like this:

<%
((MyMasterPage) this.Master).tattle("hey there");
%>
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Rik Brooks" <rb*****@hhcc.com.donotspam> wrote in message
news:08**********************************@microsof t.com...
Thank you so much Nicholas, but that confused me more than ever. First of
all, I've implemented interfaces in classes in Java, but didn't know that
you
could do that for an asp page.

Secondly, I really don't understand what you mean with your instructions.
Could I prevail upon you to give me a couple of lines as an example --- if
I
ask, pretty please?
----------------------------------------
Magic is not in the hands of the magician but in the mind of the audience.

Animadverto est verus


"Nicholas Paldino [.NET/C# MVP]" wrote:
Rik,

You can get the MasterPage instance from the Master property on your
page. Once you have that, you should be able to cast that to an instance
of
your specific page type, and call the method.

However, I would say that doing this doesn't make sense. If
anything,
you should have your master page implement an interface and then cast the
value of Master to that interface.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Rik Brooks" <rb*****@hhcc.com.donotspam> wrote in message
news:F7**********************************@microsof t.com...
> OK, now I'm getting excited. I actually created a master page and added
> two
> content place holders to it. I also added a label which will serve as a
> sort
> of one line help and a little image button beside it to turn off the
> help.
>
> I wrote a public method in the master page that looks like this:
>
> public void tattle(string as_msg)
> {
> microhelp.Text = as_msg;
> }
>
> Pretty simple. microhelp is that label that I spoke of. How can I run
> the
> tattle method from a content page?
>
> --
> ----------------------------------------
> Magic is not in the hands of the magician but in the mind of the
> audience.
>
> Animadverto est verus
>
>


Dec 23 '05 #4
Thank you so much, Nicholas. This works like a charm and will certainly serve
my purposes.
--
----------------------------------------
Magic is not in the hands of the magician but in the mind of the audience.

Animadverto est verus


"Nicholas Paldino [.NET/C# MVP]" wrote:
Rik,

Say tattle is implemented as you have it, in your master page class,
called MyMasterPage. In your page that has the content, you would do
something like this:

<%
((MyMasterPage) this.Master).tattle("hey there");
%>
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Rik Brooks" <rb*****@hhcc.com.donotspam> wrote in message
news:08**********************************@microsof t.com...
Thank you so much Nicholas, but that confused me more than ever. First of
all, I've implemented interfaces in classes in Java, but didn't know that
you
could do that for an asp page.

Secondly, I really don't understand what you mean with your instructions.
Could I prevail upon you to give me a couple of lines as an example --- if
I
ask, pretty please?
----------------------------------------
Magic is not in the hands of the magician but in the mind of the audience.

Animadverto est verus


"Nicholas Paldino [.NET/C# MVP]" wrote:
Rik,

You can get the MasterPage instance from the Master property on your
page. Once you have that, you should be able to cast that to an instance
of
your specific page type, and call the method.

However, I would say that doing this doesn't make sense. If
anything,
you should have your master page implement an interface and then cast the
value of Master to that interface.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Rik Brooks" <rb*****@hhcc.com.donotspam> wrote in message
news:F7**********************************@microsof t.com...
> OK, now I'm getting excited. I actually created a master page and added
> two
> content place holders to it. I also added a label which will serve as a
> sort
> of one line help and a little image button beside it to turn off the
> help.
>
> I wrote a public method in the master page that looks like this:
>
> public void tattle(string as_msg)
> {
> microhelp.Text = as_msg;
> }
>
> Pretty simple. microhelp is that label that I spoke of. How can I run
> the
> tattle method from a content page?
>
> --
> ----------------------------------------
> Magic is not in the hands of the magician but in the mind of the
> audience.
>
> Animadverto est verus
>
>


Dec 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Michael Herman \(Parallelspace\) | last post by:
1. What are some compelling solutions for using Master/Content pages with Web Pages? 2. If a content area has a web part zone with web parts, what is the user experience like when "editting" the...
4
by: Steve Franks | last post by:
I have this cool nested master page scenario working great. However what is the correct way to be able to access a strongly typed property at the top level master from a content page that has a...
5
by: Siva | last post by:
Hello I have a dropdownlist inside the gridview as a template column defined as follows: <asp:TemplateField HeaderText="Choose Location"> <ItemTemplate> <asp:DropDownList ID="ddlChooseLoc"...
17
by: Rob R. Ainscough | last post by:
Again another simple concept that appears NOT to be intuitive or I'm just stupid. I've read the WROX book and the example doesn't actually show how the .master page links in the other content...
6
by: Steve | last post by:
I'm trying to iterate over all the form controls in my MasterPages content page. Basically, I've got dropdowns, textboxes, etc that I want to format in Page_Load() I've added this code to my...
9
by: J055 | last post by:
Hi I have a standard asp page which uses a MasterPage. The MasterPage contains a User control. How can I access a public method in the User control from my WebForm page? I can't move the method...
3
by: vespaboy | last post by:
i need to access a <div runat="server"which sits in a master page which is itself nested in a master page. i've tried this code but it doesn't work: Page: Dim divStep1 As HtmlGenericControl =...
13
by: Kirk | last post by:
I have been reading Scott Allen's article on Master Pages (http:// odetocode.com/Articles/450.aspx) but I am having problems understanding a concept. Specifically, I have created a property...
5
by: =?Utf-8?B?bXVzb3NkZXY=?= | last post by:
Hi guys I'm trying to make my code as streamlined as possible, and add CSS file references dynamically when they are required, for example, if a page contains a webcontrol, then the related CSS...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.