ASP.NET: Web User Control calling functions in page?

  • Thread starter Thread starter planetthoughtful
  • Start date Start date
P

planetthoughtful

Hi All,

I have a Web User Control that I would like to use in several pages in
my ASP.NET application.

I'm wondering, however, if it's possible to call a function contained
in the page from within the Web User Control?

To give a little more detail:

The Web User Control itself adds and displays notes associated with an
order. When the submit button in the control is clicked, I need to call
a function that refreshes the overall data being displayed for the
order on the page. This function is called by other events as well, so
it doesn't make sense to include it within the Web User Control itself.

So, I'm wondering a) if it's possible to call a function defined in the
page in which the Web User Control is included, and b) if it is
possible, what the syntax for that would be?

Any help would be much appreciated!

Much warmth,

planetthoughtful
 
plantethoughtful,

In your control, you can access the Page property, which will return the
Page that the control is hosted in. You would then have to cast it to the
specific page type, so that you can access the functions that you have
defined in your page.

Hope this helps.
 
Nicholas said:
plantethoughtful,

In your control, you can access the Page property, which will return the
Page that the control is hosted in. You would then have to cast it to the
specific page type, so that you can access the functions that you have
defined in your page.

Hope this helps.

Hi Nicholas,

Thanks for this - I'm not sure exactly how I cast the page object as
the specific page type? Any advice on where I'd look to read about
doing this?

Many thanks!

Much warmth,

planetthoughtful
 
Back
Top