Filling a textbox on a parent web user control from a child web form


I currently have a web user control (pf_imageselector.ascx) which is dynamically created (any number of times) on a parent web user control (pf_fillitems.ascx) which in turn has been loaded into a webform (default.aspx). On the user control is a text box called txbSelectedImage and a button. On click of the button run's this code:
function OpenChild()

var strImageFile;
var WinSettings = "height=580,width=630,status=yes,toolbar=no,menubar=no,location=no";"pf_stockimage.aspx", null, WinSettings);
Which obviously open a child webform. From here the user can select something from a listbox and the click another button, which then hopefully passes back the selected value to the textbox on the parent user control. Code so far is:
function PassSelectedImage()
var lstImages = document.forms[0].lstImages;
var i = lstImages.selectedIndex;
window.opener.document.forms[0].txbSelectedImage.value = lstImages.options[i].value;
My problem is that I get an erorr stating that above is null or not an object. How do I reference the textbox that is sitting inside the user control (ID is generated at runtime), which is also sittting in another usercontrol (I know the ID of this one) on a webform (default.aspx, which as a form called Form1).
10/25/2004 10:49:27 AM 24353 articles. 1 followers. Follow

3 Replies

Similar Articles

[PageSpeed] 36


If you are generating script at server, you have to use txbSelectedImage.ClientId to determine real HTML tag id at client.
Leon Langleyben


10/25/2004 1:02:23 PM
Exactly the code I was looking for too.  Thanks for the assist!
11/15/2005 1:16:34 AM

My plesure

Leon Langleyben


11/15/2005 10:21:42 AM

Similar Artilces:

validate Textbox in Web User Control from web form?
ASP.NET 2.0 I have a web user control that contains a textbox.  I need to add some validation (like requiredfieldvalidator, comparevalidator, etc). I would normally add the validator to my web user control by placing the validator next to my textbox.  However, I need the validation message somewhere else on my web form, not near the user control. So how would I associate a validation control on my web form with the text box inside my web user control?  Can this be done; any alternatives out there? Thanks!   The error message should occur wherever you place the vali...

Refresh Web form (parent) when submiting Web User Control
I got one Web form that contains one Web user control. The web form is displaying some data that is stored in database and Web User Control to edit this data and save the changes to database. When I press submit button in user control the data is getting stored in db, but Web form is not updated with this new changes ( i think this is because of the callback ). If I refresh the page then i see the changes. How can I make user control fire the refresh event in web form? If you have a answer pls give me a example or point to one tutorial, its much easier to understand! Thanks for your time!...

Web User Control to Web User Control...
Hi, I have 2 User controls on a page and want Control1 to call a method of Control2. Is this Possible? Example: Con1 = Datalist showing products, each with a Quantity Box and a Button. Con2 = Repeater showing Cart Preview (name, Price) in page.aspx. When I click on the button on the DataList in Con1 it adds the item into the Session based Cart. However it does not update the Cart Preview. I need to call BindPreview() in Con2 in order to update the Cart Preview... Does that make sense? argh! any help much appreciated! PeteWeb Design Nottingham, UK Well I can call BindPreview() from m...

Passing values from a parent web control to child web control
I have a parent control which called CONTROL1 and a child control witch called CONTROL2 I would link to pass a value from the parent control to the child control. In the parent control(CONTROL1) I have the following Event Handler . private void btn_Handler(object sender, EventArgs e) { …      if (Page.IsPostBack) {              // Send the officer names to the child controls.             if(m_nameList.SelectedItem.Text != "")     ...

Web User Control +Client Side Control
Two Questions if Possible:  1: Some controls have methods/properties that can be gotten/set client-side (IE ASP:Timer).  Can usally access them by "$find('<%=Control.ClientID%>').get_(set_)name()".  I made a User Control that has a "Enabled" Propertiy (basically sets a bunch of its components to "visible = false" and then a Timer.Enabled=false).  I can't access my user controls "enabled" via client side script (IE $find(UserControl.ClientID).set_enabled(false)).  How do I bundle this type of fu...

Web Form and Web User Control
Hello, I have a Web User Control (ascx) that includes a button. This button has an onclick event method. This Web User control is included into a Web Form. (thru LoadControl). However, when I click on the button, the event method is not executed. What should I include in order it works fine? Thanks in advance. GAA. Using Loadcontrol is using dynamic controls and when using dynamic controls you must recreate the same dynamic controls ono postback to econstruct the page control tree. It is best if you do this during the Page PreInit event. How complex are your controls ...

access controls on web user control x from web user control Y
I have 2 web users controls in a page and I would like to get or set the selected values of a few dropdown boxes on web user control X from web user control Y and I also would like to know how to access functions that are on a web user control X from a web user control Y, is this possible? How can I do it? User can access and set the values of the User Control from .aspx page through properties,using javascript and in code-behind of aspx page.The details of it are shown below Using PropertiesIf the Sample.ascx control has two textboxes and submit button.You can access the valu...

Web User Control Not rendering in Web Form
I have created a Web User control that is made up of a Multiview with 2 views inside the Multiview. I have buttons on both views and a gridview on 1 view. My question is when I drop this Web User Control on a Web Form all I see is [MultiView"MultiView1"] and when I view the from in the browser I dont see the Web User Control. I was wondering if someone could please tell me why the Web User Control is not displaying or rendering.     Thanks In Advance Hi, Please check your aspx file for correct reference, like following example: TestControl.ascx:<%@ Control ...

custom web user control and web form
Guys,          I am trying to develop a context menu control for all of my pages. what i am trying to do is that i want the control to pick a datasource from the markup and then check whether its an xml file or a datatable. I created a class called datasource.   /**************************DataSource Class****************************/  public class DataSource { /// <summary> /// This is to identify unique elements from the markup /// </summary>protected string _ID; /// <summary> /// This will be the Datasource ID e...

Datagrid not refreshing in Parent web control even after re-binding from Child web control?
Hello .....,               I have dropped a web user control (B) in one my web user control (A). Now (A) contains control (B). After proving some data in (B) to be binded to the DataGrid control used in (A), I call the DataBind. When debugging the Items, the Count property shows the number of Items correctly, but the datagrid doesn't seems to have rendered the updated datagrid content. Please help me out of this problemThanx and Regards,Hemant...

web controls and web user control
i have a problem in a web form , I have a webform that contains a web user control which in turn contains a html input form ,the web control events don't fire up ,When I click button ,no effect ,I don't know what is the effect of the html form which is in the web user control on the web controls in the web form ?? can any one help me the web control event should be handle in the code behind page, is the event handler for the button you are clicking registered? You can try double clicking the button, should give you the default btn_click event handler in code behind. Also, make ...

Pass data from Web User Control to Web Form
I have a Web Form that contains a Web User Control. The WUC displays dynamic content. I want to change the TITLE property of the Web Form, based on the contents of the WUC. For example, if the WUC displays information about Horses, I want to change the page title to "HORSES" by passing the string to the parent Web Form. I have tried playing with parameters and such, but I can't remember how I did this in the past. PLEASE HELP!~o0 Spin-Monkey Oo~ The best way to do this is by creating a public property on your web user control and accessing that from your web form. Check ...

Access a Web User Control Method from a Web Form
I'm trying to pass the Selected Index value from a web user control in a web form to the user controls selectedIndexchanged Sub.  I can't seem to figure out how to pass the information that I need to the user control and have it execute the sub routine. In the SelectedInedxChanged Sub I have a switch Statement and I want to get the index value from the web form where the user control is located and compare it to each case and then to have it execute the code for the case that it matches. What do I need to do? Hi, I am not sure if I understood your question correctly. I su...

Interaction between Web User Control & Web form
Ok, I want to create my first Web User Control which is used for file uploading. It's very simple, consist only of the <asp:FileUpload> and <asp:Button> control. The button has one server side event which is resizing the uploaded image to two different images (stored as byte[] in the cs file). So, my question is how I can send these two arrays of type byte to the Web form where the web user control is inside. I thought it should be possible to write something like this in the Web form:<uc1:FileUploader ID="uploader" runat="server" OnUploaded="recieveImages" />So that means ...

Web resources about - Filling a textbox on a parent web user control from a child web form -

Filling station - Wikipedia, the free encyclopedia
A filling station , fuelling station , garage , gasbar (Canada), gas station (United States and Canada), petrol bunk or petrol pump (India), ...

Santa Filling Christmas Stockings for iPhone 3GS, iPhone 4, iPhone 4S, iPhone 5, iPod touch (3rd generation) ...
Get Santa Filling Christmas Stockings on the App Store. See screenshots and ratings, and read customer reviews.

Blue Filling (34th/52) - Flickr - Photo Sharing!
I've been feeling rather uninspired lately. I do have a few photo ideas/concepts but they all require objects that I don't have on hand. Maybe ...

Drone Shows Thousands Filling Hong Kong Streets - YouTube
Thousands of demonstrators turned out in downtown Hong Kong on September 29 to support a protest over Beijing’s decision to reject calls for ...

Speed traps ignoring safety and filling government pockets
Since when was the solution to the problem of signs that were too small and difficult to see, to replace them with no signs at all?

Need a filling? Stone Age dentists knew their beeswax
Need a filling? Stone Age dentists knew their beeswax

Cotter Dam is filling Canberra with drought confidence
The equivalent of 150% the capacity of the original Cotter Dam has been added to the ACT's water reserves in the past 10 days.

Filling the void in life after footy
A huge number of former players have little or no idea about what to do with the rest of their lives. It's a problem that needs to be addressed. ...

Filling Toff Grammar's coffers
The government should put Zaky Mallah on a retainer for weeks like this. Whenever a minister gets himself into a spot of bother, the Zackster ...

AM - Kevin Rudd faces huge task of filling gaping holes in his Cabinet 27/06/2013
Yesterday will go down in history books as a remarkable day in Australian politics The countrys first female prime minister was removed by Caucus ...

Resources last updated: 12/27/2015 6:23:53 PM