This is a discussion on "Filling a textbox on a parent web user control from a child" within the ASP.NET Forum section. This forum, and the thread "Filling a textbox on a parent web user control from a child are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
Filling a textbox on a parent web user control from a child
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
Filling a textbox on a parent web user control from a child
Hi,
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,menuba r=no,location=no"; window.open("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; window.close(); } 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). |
|
|
|
|||
|
Have you tried referencing your control via "getElementById"? E.G.,
window.opener.document.forms[0].getElementById("txbSelectedImage").value = lstImages.options[i].value; HTH |
|
|||
|
Tried that... all I get then is an error message stating "Object doesn't support this property or method"...
|
|
|||
|
On your popup page, give the form tag a name:
If you are still having problems getting the value from your selected item in your popup, try this:
HTH |
|
|||
|
This belongs in the javascript section...
|
|
|||
|
You sure this is not jscript.net?
|
|
|||
|
yeah fairly sure! what do you reckon?
|
|
|||
|
I am not sure
Ohh, how I love egg on my face |
![]() |
| Tags |
| filling, textbox, parent, web, user, control, child |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Child div expand to fit parent? | linchpin311 | Web Page Design | 5 | Apr 20th, 2008 21:16 |
| Javascript Parent and Child menu in Safari?? | TR123 | JavaScript Forum | 3 | Mar 8th, 2007 14:15 |
| Submitting a parent form from a child window in IE 7 | livehed | JavaScript Forum | 0 | Feb 15th, 2007 16:23 |
| parent child forms | mrproggie | ASP.NET Forum | 1 | Aug 12th, 2006 17:49 |
| Parent Child accesssing | greenkhan | ASP.NET Forum | 1 | Jun 20th, 2005 09:21 |