By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,669 Members | 1,671 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,669 IT Pros & Developers. It's quick & easy.

Accessing method in master page from content page

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.