Access Child Method From Master Page in C#?

N

Nigil Chua

Hi There,

I know I can access a Master Page Method From Child Page by Using
(ClassName)Page.Master on the child Page.
but how do I have access a Child Page Method From Master Page.
Does anyone know how should I go about on it?

Best Regards,
Nigil Chua
 
C

Cowboy \(Gregory A. Beamer\)

Does a person drive a car or does a car drive a person?

This is a good question, in abstract, as this is what is occuring on your
page.

Think about a server control for a second, like a textbox. Can you contact
the page from the textbox? No. It is an encapsulated bit of code that sits
on the page. What about a user control? Used properly it should be no
different than a server control. You should code it so the page can contact
it's properties and methods, but so that it has to raise events to talk back
to the page. While you can circumvent this behavior, you end up with the car
driving the person.

A master page is a form of user control that allows for common functionality
and look and feel on all of your pages. It is rather abstract, from the
user's perspective, as you cannot invoke a master page outside of a page.
This should tell you that the page is in control.

Now, you are asking, can I give some control to the master page? While it
might be technically possible, you should ask yourself whether it is a good
idea or not. The second question, after answering no to the first, is
whether there is another way to solve what you desire.

You can use Content regions to add placeholders on pages. This is a way to
abstractly give the page the ability to add code. It is not the master page
calling events on the page, of course.

Now, perhaps you have found a reason why a car should drive a person. In the
world of software, anything is possible, but rather than ask how to do
something, you should state why you need to know, as someone may be able to
lead you to a more proper solution.

I hope I am not being too blunt here. If nobody sees this response, you may
get an answer on how to achieve what you desire, but I would ask whether or
not it is the proper method of solving your problem.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

*************************************************
| Think outside the box!
|
*************************************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top