Solved

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

Posted on 2010-11-09
5
342 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
  • 3
  • 2
5 Comments
 
LVL 13

Accepted Solution

by:
gamarrojgq earned 250 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 250 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

705 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now