• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 360
  • Last Modified:

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

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
Lorna70
Asked:
Lorna70
  • 3
  • 2
2 Solutions
 
gamarrojgqCommented:
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
 
Lorna70Author Commented:
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
 
gamarrojgqCommented:
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
 
Lorna70Author Commented:
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
 
Lorna70Author Commented:
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.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now