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

Calling parent methods from a child

P: n/a
Jim
I have a user control that has two nested user controls within it. I have a
method in the parent called CloseDetailsMaint, and I need to be able to call
it from one of the child user controls that is nested within the parent. How
do I do this?
Nov 19 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Parent.Page
You may have to cast it, and make sure it's set to Public in the parent

--
Curt Christianson
Site & Scripts: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Jim" <Ji*@discussions.microsoft.com> wrote in message
news:21**********************************@microsof t.com...
I have a user control that has two nested user controls within it. I have
a
method in the parent called CloseDetailsMaint, and I need to be able to
call
it from one of the child user controls that is nested within the parent.
How
do I do this?

Nov 19 '05 #2

P: n/a
Jim
I tried Parent. Page.CloseDetailsMaint ();, but I got an exception during the
build saying that System.Web.UI.Page does not contain a definition for
"CloseDetailsMaint". Any ideas? The method is public and returns void.

"Curt_C [MVP]" wrote:
Parent.Page
You may have to cast it, and make sure it's set to Public in the parent

--
Curt Christianson
Site & Scripts: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Jim" <Ji*@discussions.microsoft.com> wrote in message
news:21**********************************@microsof t.com...
I have a user control that has two nested user controls within it. I have
a
method in the parent called CloseDetailsMaint, and I need to be able to
call
it from one of the child user controls that is nested within the parent.
How
do I do this?


Nov 19 '05 #3

P: n/a
((MyParentPage)Page).CloseDetailsMaint ();

"Jim" <Ji*@discussions.microsoft.com> pí¹e v diskusním pøíspìvku
news:4D**********************************@microsof t.com...
I tried Parent. Page.CloseDetailsMaint ();, but I got an exception during
the
build saying that System.Web.UI.Page does not contain a definition for
"CloseDetailsMaint". Any ideas? The method is public and returns void.

"Curt_C [MVP]" wrote:
Parent.Page
You may have to cast it, and make sure it's set to Public in the parent

--
Curt Christianson
Site & Scripts: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Jim" <Ji*@discussions.microsoft.com> wrote in message
news:21**********************************@microsof t.com...
>I have a user control that has two nested user controls within it. I
>have
>a
> method in the parent called CloseDetailsMaint, and I need to be able to
> call
> it from one of the child user controls that is nested within the
> parent.
> How
> do I do this?


Nov 19 '05 #4

P: n/a
You can Raise an Public Event in the child control, and this event is
implemented in the parent control, and there you can call the method you
need.

Atte. Elmer Carías
"Jim" <Ji*@discussions.microsoft.com> wrote in message
news:21**********************************@microsof t.com...
I have a user control that has two nested user controls within it. I have a method in the parent called CloseDetailsMaint, and I need to be able to call it from one of the child user controls that is nested within the parent. How do I do this?

Nov 19 '05 #5

P: n/a
Jim,
While you've gotten your answer from others,you might want to take a look at
http://openmymind.net/communication/index.html which discusses strategies
to do this sort of thing.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Jim" <Ji*@discussions.microsoft.com> wrote in message
news:21**********************************@microsof t.com...
I have a user control that has two nested user controls within it. I have a method in the parent called CloseDetailsMaint, and I need to be able to call it from one of the child user controls that is nested within the parent. How do I do this?

Nov 19 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.