Current location: Hot Scripts Forums » Programming Languages » ASP.NET » Filling a textbox on a parent web user control from a child web form


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

Reply
  #1 (permalink)  
Old 10-25-04, 06:17 AM
neilault neilault is offline
New Member
 
Join Date: Oct 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Angry Filling a textbox on a parent web user control from a child web form

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).
Reply With Quote
  #2 (permalink)  
Old 11-14-04, 10:32 PM
thuenb thuenb is offline
Newbie Coder
 
Join Date: Oct 2004
Location: MI
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Try using Sessions...

An easy way to pass params around a site is too use sessions...

For instance...
On the parent page use the following code added to the button click event. Note this code is in vb.net
Code:
Session.item("myVariable") = textbox1.text
On the Child page use the following code added to
' the page load event...

Code:
if not ispostback then
    NewTextBox.Text = Session.item("myVariable")
end if
I now this is an example using a textbox and a string variable, but any variables can be assigned to a session item... Just make sure you aren't loading HUGE amounts of data into session items, and you will be fine.
__________________
Best Regards,
Brian Thuen
http://www.AdvisedSolutions.com
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
query a 3 child table to get a parent name(mysql) rani PHP 0 07-02-04 01:25 AM
Need Epinions-lite system in PHP & MYSQL wali001 Job Offers & Assistance 4 01-12-04 06:02 AM


All times are GMT -5. The time now is 12:56 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.