Solved

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

Posted on 2010-11-09
5
351 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 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
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…

726 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