HELP - Passing Date from PopUp ASPX via JavaScript

B

billy

Ok, here's the situation... I have a user control that contains two
textboxes (one for a from date/time and one for a to date/time) and two
image buttons. The user control itself is supposed to be used on a number
of different ASPX pages (that's why I made it a ASCX). When clicking the
image button, I run simple JavaScript to open another popup ASPX page that
contains a calendar control and two dropdownboxes for the time (hours :
minutes). Once the user selects their date and time on the popup ASPX page,
they then click a linkbutton ("Ok") to close the popup and pass the selected
date and time back to the textbox on the user control, which is part of the
main ASPX page. Make sense? I'm trying to use
window.opener.document.form.textbox.value= to send the value back. I also
tried window.opener.document.form.usercontrol.textbox.value=, and that
didn't work either.

The problem I'm having is that I cannot get the value back from the popup
ASPX form to the textbox on the user control. It seems as if the JavaScript
window.opener method doesn't know how to find the user control on the main
ASPX page.

Does anyone know how to solve such an issue?
Or, does anyone have any better solutions to my design?

Thanks.
 
C

Craig Deelsnyder

Ok, here's the situation... I have a user control that contains two
textboxes (one for a from date/time and one for a to date/time) and two
image buttons. The user control itself is supposed to be used on a
number
of different ASPX pages (that's why I made it a ASCX). When clicking the
image button, I run simple JavaScript to open another popup ASPX page
that
contains a calendar control and two dropdownboxes for the time (hours :
minutes). Once the user selects their date and time on the popup ASPX
page,
they then click a linkbutton ("Ok") to close the popup and pass the
selected
date and time back to the textbox on the user control, which is part of
the
main ASPX page. Make sense? I'm trying to use
window.opener.document.form.textbox.value= to send the value back. I
also
tried window.opener.document.form.usercontrol.textbox.value=, and that
didn't work either.

The problem I'm having is that I cannot get the value back from the popup
ASPX form to the textbox on the user control. It seems as if the
JavaScript
window.opener method doesn't know how to find the user control on the
main
ASPX page.

Does anyone know how to solve such an issue?
Or, does anyone have any better solutions to my design?

Thanks.

I assume you've seen examples on the web like the following:

http://www.dotnetjohn.com/articles.aspx?articleid=67

The thing to be careful of is that you should always make dynamic any JS
that uses element IDs directly. Meaning this: when you put a textbox
inside a usercontrol, its id in the resulting html ends up being basically
its id with the usercontrol's id appended to it at the front. View the
source of your HTML and you'll see what I mean.

So basically you need to dynamically create the JS that happens in the <a
onclick to use the textbox's .ClientID instead (this property will give
you the ID in the resulting HTML), not the ID you named it in the .ascx.

Make sense? Many examples on the web don't point this out...that the ID
in the resulting HTML may be different if your textbox is inside a naming
container (like user control)....which is why using .ClientID all the time
is safest, and dynamically generating your script....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,152
Latest member
LorettaGur
Top