473,544 Members | 911 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1939
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.co m

"Rik Brooks" <rb*****@hhcc.c om.donotspam> wrote in message
news:F7******** *************** ***********@mic rosoft.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.co m

"Rik Brooks" <rb*****@hhcc.c om.donotspam> wrote in message
news:F7******** *************** ***********@mic rosoft.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).ta ttle("hey there");
%>
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Rik Brooks" <rb*****@hhcc.c om.donotspam> wrote in message
news:08******** *************** ***********@mic rosoft.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.co m

"Rik Brooks" <rb*****@hhcc.c om.donotspam> wrote in message
news:F7******** *************** ***********@mic rosoft.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).ta ttle("hey there");
%>
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Rik Brooks" <rb*****@hhcc.c om.donotspam> wrote in message
news:08******** *************** ***********@mic rosoft.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.co m

"Rik Brooks" <rb*****@hhcc.c om.donotspam> wrote in message
news:F7******** *************** ***********@mic rosoft.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
2403
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 web part page? Does it take place at the page level? ...or the content area level? 3. Where is the Web Part Manager instantiated? ...in the...
4
2457
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 nested master page between the content page and the top level master? For example, assume the very top level master is called CompanyWide.master....
5
2744
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" runat="server"> </asp:DropDownList> </ItemTemplate> </asp:TemplateField> I have the gridview inside of a master page- content hierarchy.
17
3136
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 pages? Kinda sorta a critical point no? Am I missing something? Rob. P.S. the day I find a book that actually is useful rather than just a
6
3258
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 Page_Load() event <code> private void ConfigureFormControls() { Color borderColor = ColorTranslator.FromHtml("#F5F5F5"); Color fontColor ...
9
2635
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 to another location because it populates a Textbox in the user control page. Thanks Andrew
3
4082
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 = CType(Master.FindControl("divStep1"), HtmlGenericControl) Master page:
13
5292
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 (called "CurFlag") on my master page that can be accessed from content pages, but not from separate code modules. I tried doing something like this in...
5
2703
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 file is added by the webcontrol. This prevents me having to remember to add the CSS file to the page if I use a certain webcontrol. I have a...
0
7368
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7614
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7777
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
5916
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4922
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3420
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3414
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1844
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
671
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.