473,508 Members | 2,367 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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?

Jan 3 '06 #1
1 1938
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.)
"engwar" wrote:
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?

Jan 3 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
3137
by: Alphonse Giambrone | last post by:
I have a web form with 2 user controls on it (UC1 and UC2). Each control has a bound datagrid with textboxes in the footer to add a new row. There are also requiredfieldvalidators in each footer....
7
5302
by: Max | last post by:
How do I declare in the parent page's code behind a user control? I want to call a sub that is located in the user control. Want to do something like this: Call MyUserControl.MySub()
7
7715
by: moondaddy | last post by:
I have a user control being used instead of a frame page. when the user clicks on a menu item I need to send the ID (integer value) of that menu as a parameter in the postback of the user control...
1
3572
by: moondaddy | last post by:
I need to replace a user control on a page with a different user control. The challenge I'm faced with is that this call is being made from the user control being replaced. Normally I replace...
6
12261
by: grist2mill | last post by:
I want to create a standard tool bar that appears on all pages that is a control. The toolbar has a button 'New'. What I wolud like when the user clicks on 'New' depends on the page they are on. I...
10
5781
by: sqlboy2000 | last post by:
Hello all, I have something very simple going on here and I'm scratching my head as to what the problem is. There are 4 items in my project, 2 webforms, a user control, and a module: ...
2
13446
by: engwar1 | last post by:
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...
4
1677
by: tshad | last post by:
Is there a way for a User Control to access an object (such as label or textbox) on the .aspx page that calls it? For example: x.aspx ************************************** .... Sub...
5
2150
by: rn5a | last post by:
Consider the following user control which resides in Address.ascx: <script runat="server"> Public Property Address() As String Get Address = txtAddress.Text End Get Set(ByVal value As String)...
7
2992
by: | last post by:
I have what's probably a simple page lifecycle question related to dynamically evaluating values that are placed by a repeater and dynmically placing user controls that use those values. I'm...
0
7223
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7115
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...
0
7321
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,...
1
7036
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
3191
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...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1547
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 ...
1
762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
414
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...

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.