473,748 Members | 2,595 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

HELP - Passing Date from PopUp ASPX via JavaScript

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.d ocument.form.te xtbox.value= to send the value back. I also
tried window.opener.d ocument.form.us ercontrol.textb ox.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.


Nov 19 '05 #1
1 2220
On Wed, 27 Jul 2005 10:28:21 -0500, billy <bi***@nospam.c om> 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.d ocument.form.te xtbox.value= to send the value back. I
also
tried window.opener.d ocument.form.us ercontrol.textb ox.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)....whi ch 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
4345
by: Raju V.K | last post by:
can I use javascript and PHP in the following manner to create a pop-up window: <--- in <head> </head> <script language=javascript> function popup(folder1, file1) { window1=open("solution.php?folder=folder1&file=file1"); }
2
3513
by: luna | last post by:
ive read a few tutorials but im still not getting anywhere (most code ive seen is code inline - im using codebehind VB and aspx) im creating a link button that opens a popup calendar that once a date is picked it posts back and populates the form i think i know where the error lies im just unsure how to fix it my code is like this :- the form is called form1 and the page is called test.aspx {
4
2680
by: Chris | last post by:
Hi, I am trying to create a popup calender so a user can click on a button on the main form, a calender will then popup, the user will select a date and then click ok on the popup. The date will then be passed back to the main form and populate a textbox. I tried two options. None worked. First. I used the popup calender form the time tracker starter kit. On my page I have an image buton. In the click event I have the foll code
5
2042
by: Chris | last post by:
Hi, I have been trying for days, yes days, to use the calender from the asp.net timetracker starter kit. I am now frustrated. I finally get the popup calender to popup but when I click ok to insert the date to the calling page I get the error "A runtime error has occured Line 14
8
9025
by: Bishoy George | last post by:
how to let javascript code understand txtUser.Text? in window.open("WebForm26.aspx?User=txtUser.Text",.....................)
1
2528
by: Seok Bee | last post by:
Dear Experts, Currently I am creating a webform using sp.net 2.0. I would like to create a date picker in my webform. I managed to create a a button to call-up the calendar and using the Calendar control from the toolbox. I would like to know how can I pass the value back to a textbox in my original form with the selected date from the calendar? Also, can I have the selection of the time as well? Regards,
3
2772
by: Learner | last post by:
Hello, I have two buttons on one of my VehicleDetails.aspx page. Obiviously these two buttons takes the user to two different pages. Now my client is interested in having a linkbutton instead of the two buttons. Once the user clicks on the linkbutton a javascript dialog box popsup that says "Is the Lessee buying this vehicle?" and with two buttons "Yes" and "No". If user clicks "yes" it should go to DealerQuestions.aspx" and if "No" it...
2
3156
by: sorobor | last post by:
dear sir .. i am using cakephp freamwork ..By the way i m begener in php and javascript .. My probs r bellow I made a javascript calender ..there is a close button ..when i press close button then the calender gone actually i want if i click outside off the calender then it should me removed ..How kan i do this ... Pls inform me as early as possible .. I am waiting for ur quick replay ...Here i attached the source code .... <!DOCTYPE...
4
4162
by: moondaddy | last post by:
I have a htm page where I need to pass some data to an aspx page as a means of sending data to the database. I don't need to see the aspx page so I was going to put it in a hidden iframe. This works real good. Since I don't need the aspx page to do any postback, is there a way to pass a parameter to it with out it finishing the round trip back to the htm page? Thanks. -- moondaddy@newsgroup.nospam
0
8991
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8830
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9541
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9321
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9247
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6074
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4874
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2782
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2215
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.