Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Using popup window from control in DetailsView - problems assigning value to control

Posted on 2010-11-09
5
Medium Priority
?
354 Views
Last Modified: 2012-05-10
Hi I'm calling a javascript Datepicker function from a TextBox control in DetailsView and after selecting a date I have to assign the date value to my TextBox control.  My controls are named as follows:
Form with ID="form1"
Details view with ID="dvRoute"
TextBox with ID="txtRouteDate"

My code is:
var ctl = "dvRoute_txtRouteDate";
window.opener.document.form1[ctl].value = dateValue;

This is not working - is there another way to do this or is my syntax wrong?

0
Comment
Question by:Lorna70
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 13

Accepted Solution

by:
gamarrojgq earned 1000 total points
ID: 34093154
HI,

When you say "is not working" you mean that the date value is not assign or it gives you an error?

You can try with getElementById like this.

window.opener.document.getElementById(ctl).value = dateValue;

Just when your page is loaded, see the Source Code generated in your browser to confirm the name of your Textbox Control.


0
 

Author Comment

by:Lorna70
ID: 34093534
Thanks tried that and still get a similar errorL
Microsoft JScript runtime error: 'window.opener.document.getElementById(...)' is null or not an object

I think my problem is not knowing how to reference a TextBox which is inside a DetailsView which is inside a Form.  I tried:

ctl = "form1_dvRoute_txtRouteDate";
What is the correct syntax for doing this?  Should I be using [] instead of _??
0
 
LVL 13

Assisted Solution

by:gamarrojgq
gamarrojgq earned 1000 total points
ID: 34093766
That will depend on you page, are you using master pages?

Anyway, the best way to know the real name that is assigned to you textbox is view the Source Code of you page in your browser by right clicking on your page and selecte VIEW SOURCE, and search for you textbox name , in your case txtRouteDate, and you will se the real name.

Besides, if your textbox is inside  a DetailsView perhaps it will have a number somtehing like, txtRouteDate1, txtRouteDate2, etc, depending on the row.
0
 

Author Comment

by:Lorna70
ID: 34094207
OK - my text box is "dvRoute$txtRouteDate" in the source but it still doesn't work.  Should I add the form name to the ctl var before I run:

var ctl = "dvRoute$txtRouteDate"
window.opener.document.getElementById(ctl).value = dateValue;

??
0
 

Author Comment

by:Lorna70
ID: 34094260
It worked!

For anyone else struggling with this - I went back to using:

var ctl = "dvRoute$txtRouteDate"
window.opener.document.form1[ctl].value = dateValue;
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question