473,624 Members | 2,426 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 1944
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
3171
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. When I try to add a new row to UC1 the requiredfieldvalidators for UC2 fire and therefore the page is not posted. If I remove one control, everything works fine. I have 2 questions. 1. How can I get the validators for each control to only...
7
5307
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
7726
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 which will be used to query sql server to repopulate the datagrid in the user control. I also wrapped the user control in a panel element so I could position it on the page. I'm clueless on how to get started with this.
1
3585
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 one user control with another user control like this 'Using vb.net 1.1 ctl = LoadControl(ctlPath) Me.cellControlHolder.Controls.Clear() Me.cellControlHolder.Controls.Add(ctl)
6
12275
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 would like to do this by defining a NewFunc() that is different in each (code-behind) page which is called by the standard 'New' button in the toolbar. How can I get this to work? So far I have the following (which doesnt work). When the user...
10
5801
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: WebForm1.aspx ChangeValue.aspx WebUserControl1.ascx Module1.vb
2
13456
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 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...
4
1681
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 Page_Load(s as Object, e as EventArgs) LoadControl("x.ascx")
5
2157
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) txtAddress.Text = value End Set
7
2999
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 attempting to bind a user control I've written, "ImageBox", to a repeater. The user control takes a custom property, "ContentID", that will execute a database lookup and load an image.
0
8240
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8175
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8625
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6111
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5565
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4177
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2610
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 we have to send another system
1
1791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1487
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.