By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,813 Members | 1,257 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,813 IT Pros & Developers. It's quick & easy.

HELP - Passing Date from PopUp ASPX via JavaScript

P: n/a
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.va lue=, 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.


Nov 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Wed, 27 Jul 2005 10:28:21 -0500, billy <bi***@nospam.com> wrote:
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.va lue=, 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....

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
Nov 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.