Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / July 2005

Tip: Looking for answers? Try searching our database.

HELP - Passing Date from PopUp ASPX via JavaScript

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
billy - 27 Jul 2005 16:28 GMT
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.
Craig Deelsnyder - 27 Jul 2005 19:23 GMT
> 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
[quoted text clipped - 27 lines]
>
> 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....

Signature

Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.