Can a user control call a method in the 'parent' aspx page?

E

engwar

I have a page that my users will go to to upload files to my website.
As I want to reuse the file upload code on multiple pages I put the
file upload textbox/buttons on a user control which I plan to include
in multiple aspx pages where they'll be able to upload images for other
purposes.

On the first page that I'm working on where users will be doing the
upload (which I'll call the 'parent' page) I also have a DataGrid where
I display the images that the user has already uploaded. The problem
I'm running into is that the code that hits the database and binds the
dataset to the DataGrid only runs when the page loads for the first
time. And I can't determine how to call my DataBind method from the
method in my user control that runs when a person actually uploads a
new image.

So the image does get uploaded but the DataGrid doesn't refresh
displaying the most recent image that's just been added.

I can re-write my code to not use a user control. I'd have similar code
repeated multiple times in 3 or 4 .aspx pages (which I'd like to
avoid.)

Any ideas? Can you call a method in an aspx.cs page from the
code-behind of a user control included in that page?
 
G

Guest

engwar,

If you need to notify the parent from within the user control, that
something has occurred, you use events and let the parent to handle it the
way they need (e.g. re-bind the datagrid, display a confirmation message,
etc.)
 

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