[Javascript] DHTML\AJax\WebParts\JavaScript

Gene Berger list_mail at att.net
Fri Jan 23 08:38:07 CST 2009


Just a post of the solution (perhaps it can help someone else).


HTML CONTROLS THAT OPENS POPUP
// text box next is for a Date
<asp:TextBox ID="txt_DtG1_TargetDate" value="01/01/2009" Runat="server" />
<a href="JavaScript:;"
onclick="popwindow('WebPartManager1$gwpEdit_Project$Edit_Project$txt_DtG1_Ta
rgetDate');">

JAVASCRIPT IN "MAIN" WINDOW
function popwindow(ID)
{
var textDate = document.getElementById(ID).value;
//alert(ID.toString());
var controlID =
ID.replace('WebPartManager1$gwpEdit_Project$Edit_Project$','');
window.open('popup.aspx?textbox='+textDate,controlID,'width=250,height=225,l
eft=270,top=180')
}


POPUP WINDOW CODE BEHIND (vb.Net)
Protected Sub Change_Date(ByVal sender As System.Object, ByVal e As
System.EventArgs)
  ' THIS IS A CALENDAR CONTROL
  ' This piece of code updates the MAIN window from the popoup
  Dim dtm As DateTime = calDate.SelectedDate
  Dim strScript As String = "<script type='text/javascript'
language='javascript'>"
  strScript += "var Calender=" & "'" &
calDate.SelectedDate.ToString("MM/dd/yyyy") & "' ;"
  strScript += "var  controlId
='WebPartManager1$gwpEdit_Project$Edit_Project$'+ window.name ;"
  strScript += "var array  = new Array(controlId,Calender);"
  strScript += "window.opener.update(array);"
  strScript += "self.close();"
  strScript += "</script>"
  RegisterClientScriptBlock("anything", strScript)
End Sub


-----Original Message-----
From: javascript-bounces at lists.evolt.org
[mailto:javascript-bounces at lists.evolt.org] On Behalf Of Peter Brunone
Sent: Thursday, January 22, 2009 3:04 PM
To: JavaScript List
Subject: Re: [Javascript] DHTML\AJax\WebParts\JavaScript

That "I don't know" piece is probably just the ID of a control that 
contains the ascx.

The reference to the opener window will not be affected by the HTML around 
the script; the DOM isn't confused when you directly address "window" 
(unless you're inside a frame).

----------------------------------------

From: "Gene Berger" <list_mail at att.net>
Sent: Thursday, January 22, 2009 1:53 PM
To: "JavaScript List" <javascript at lists.evolt.org>
Subject: Re: [Javascript] DHTML\AJax\WebParts\JavaScript 

Thanks to all that replied. 

The problem with this was the web form is a web part (i.e. SharePoint) 
which
contains a User Control which the control is hosted in. I couldn't get a
reference to the control from "outside" of the form that contained the
control.

The correct syntax is:

WebPartManager1$gwpEdit_Project$Edit_Project$txt_DtG3_TargetDate

WebPartManager1 : The name of the WebPartManager
gwpEdit_Project : I actually have no idea what this is. It is
inserted by Microsoft upon screen generation.
Edit_Project : The name of the .ascx page
txt_DtG3_TargetDate : The ID of the control.

-----Original Message-----
From: javascript-bounces at lists.evolt.org
[mailto:javascript-bounces at lists.evolt.org] On Behalf Of Peter Brunone
Sent: Thursday, January 22, 2009 10:27 AM
To: JavaScript List
Subject: Re: [Javascript] DHTML\AJax\WebParts\JavaScript

Sounds like we'd really benefit from seeing the JS output (as opposed to 
the string-building code). FYI, window.opener is the proper syntax for 
getting a reference to the window which opened the current window.

One notable exception to the window.opener syntax is cross-domain 
scripting, i.e. when you're trying to send values between windows that have 

different sites open. Most current browsers will prevent you from doing so 

due to security concerns.

Peter

----------------------------------------

From: "Gene Berger" list_mail at att.net

Whoops ... 

I have tried the commented-out code. I can't seem to get a reference to 
the
calling web page to send back the value to the calling page. The 
JavaScript
errors I get are always along the line of "object is null or doesn't 
exist".
(The object being the parent window calling the popup.)

-----Original Message-----
From: javascript-bounces at lists.evolt.org
[mailto:javascript-bounces at lists.evolt.org] On Behalf Of Peter Brunone
Sent: Wednesday, January 21, 2009 4:34 PM
To: JavaScript List
Subject: Re: [Javascript] DHTML\AJax\WebParts\JavaScript

Gene,

Are you getting a Javascript error message? If so, what does it say? 
If not -- or even if so -- what does the Javascript look like when it's 
rendered in the HTML source?

I'm a little confused since most of the code here is commented out; 
what parts are actually relevant?

Peter

_______________________________________________
Javascript mailing list
Javascript at lists.evolt.org
http://lists.evolt.org/mailman/listinfo/javascript

_______________________________________________
Javascript mailing list
Javascript at lists.evolt.org
http://lists.evolt.org/mailman/listinfo/javascript

 
_______________________________________________
Javascript mailing list
Javascript at lists.evolt.org
http://lists.evolt.org/mailman/listinfo/javascript




More information about the Javascript mailing list