popup calendar HELP!!

J

Joe Bonavita

I'm trying to use a popup calendar in my web form and I'm having a very,
very hard time with it.
I have to popup working but I can't get the date back to the parent who
opened it.

My parent unit is called WebForm1.aspx and the child (calendar form) is
called calendar.aspx

This is driving me CRAZY!

Here's what I have:

In the parent:
public void GetDate()

{

string sURL = "Calendar.aspx";

StringBuilder sbScript = new StringBuilder();

StringBuilder sbFeatures = new StringBuilder();

// Change these to specifications required for the window...


sbFeatures.Append("left=300,top=300,width=325,height=300,");

sbFeatures.Append("menubar=no,resizable=no,scrollbars=yes,");

sbFeatures.Append("status=no,titlebar=no,toolbar=no");

sbScript.Append("<script language=\"JavaScript\"
type=\"text/javascript\">\n");

sbScript.Append("//<!--\n");

sbScript.Append("var oPopupWindow = window.open(");

sbScript.Append("\'" + sURL + "\', ");

sbScript.Append("\'_blank\', ");

sbScript.Append("\'" + sbFeatures.ToString() + "\');\n");

sbScript.Append("\n");

sbScript.Append("oPopupWindow.focus();\n");

sbScript.Append("\n");

sbScript.Append("//-->\n");

sbScript.Append("</script>\n");

RegisterStartupScript("PopupWindowScript1",

sbScript.ToString());

}



In the Child:

private void SetDate()

{

string sURL = "Calendar.aspx";

StringBuilder sbScript = new StringBuilder();

// Change these to specifications required for the window...


sbScript.Append("<script language=\"JavaScript\"
type=\"text/javascript\">\n");

sbScript.Append("//<!--\n");

sbScript.Append("debugger;");

sbScript.Append("window.opener.document.forms[0].lblArrivalPreivewDate.value
='" + Calendar1.SelectedDate + "';");

sbScript.Append("\nwindow.close();\n");

sbScript.Append("\n");

sbScript.Append("//-->\n");

sbScript.Append("</script>\n");

RegisterStartupScript("PopupWindowScript3",

sbScript.ToString());

}

Thanks in advance - Joe
 
J

James Radke

Joe,

You can do it one of two ways:

1.) Set a session variable in the calendar.aspx, since the popup window was
created from the original window, they will share the same session
variables.

or

2) When you close the popup window you can return a value to the javascript
which you can then set to a field on the web page..... Something like this
from the close function of the popup window:


Response.Write("<script>window.returnValue='somevalue';window.close()</scrip
t>")

This will close the pop-up window, and pass a return value (here the text
'somevalue') back to the javascript as the result of the pop-up window
dialog.

The method chosen will depend on what processing you want to do immediately
after the date has been selected, if any.

Does that help?

Jim

Joe Gass said:
You could try this pop up calendar control instead
http://www.excentricsworld.com/customcontrols.aspx?id=7

Joe Bonavita said:
I'm trying to use a popup calendar in my web form and I'm having a very,
very hard time with it.
I have to popup working but I can't get the date back to the parent who
opened it.

My parent unit is called WebForm1.aspx and the child (calendar form) is
called calendar.aspx

This is driving me CRAZY!

Here's what I have:

In the parent:
public void GetDate()

{

string sURL = "Calendar.aspx";

StringBuilder sbScript = new StringBuilder();

StringBuilder sbFeatures = new StringBuilder();

// Change these to specifications required for the window...


sbFeatures.Append("left=300,top=300,width=325,height=300,");

sbFeatures.Append("menubar=no,resizable=no,scrollbars=yes,");

sbFeatures.Append("status=no,titlebar=no,toolbar=no");

sbScript.Append("<script language=\"JavaScript\"
type=\"text/javascript\">\n");

sbScript.Append("//<!--\n");

sbScript.Append("var oPopupWindow = window.open(");

sbScript.Append("\'" + sURL + "\', ");

sbScript.Append("\'_blank\', ");

sbScript.Append("\'" + sbFeatures.ToString() + "\');\n");

sbScript.Append("\n");

sbScript.Append("oPopupWindow.focus();\n");

sbScript.Append("\n");

sbScript.Append("//-->\n");

sbScript.Append("</script>\n");

RegisterStartupScript("PopupWindowScript1",

sbScript.ToString());

}



In the Child:

private void SetDate()

{

string sURL = "Calendar.aspx";

StringBuilder sbScript = new StringBuilder();

// Change these to specifications required for the window...


sbScript.Append("<script language=\"JavaScript\"
type=\"text/javascript\">\n");

sbScript.Append("//<!--\n");

sbScript.Append("debugger;");
sbScript.Append("window.opener.document.forms[0].lblArrivalPreivewDate.value
='" + Calendar1.SelectedDate + "';");

sbScript.Append("\nwindow.close();\n");

sbScript.Append("\n");

sbScript.Append("//-->\n");

sbScript.Append("</script>\n");

RegisterStartupScript("PopupWindowScript3",

sbScript.ToString());

}

Thanks in advance - Joe
 
J

Joe Bonavita

I'm not too sure I know what you mean. When I call my GetDate function it
opens the calendar window and returns.

If I have the script return a value, how or where do I get this value in the
parent window?

James Radke said:
Joe,

You can do it one of two ways:

1.) Set a session variable in the calendar.aspx, since the popup window was
created from the original window, they will share the same session
variables.

or

2) When you close the popup window you can return a value to the javascript
which you can then set to a field on the web page..... Something like this
from the close function of the popup window:
Response.Write( said:
t>")

This will close the pop-up window, and pass a return value (here the text
'somevalue') back to the javascript as the result of the pop-up window
dialog.

The method chosen will depend on what processing you want to do immediately
after the date has been selected, if any.

Does that help?

Jim

Joe Gass said:
You could try this pop up calendar control instead
http://www.excentricsworld.com/customcontrols.aspx?id=7
sbScript.Append("window.opener.document.forms[0].lblArrivalPreivewDate.value
 
J

James Radke

Joe,

It would be something like this.... Note: I use an .HTM form which has a
frame and the aspx form within that frame to keep from starting a second
window... kind of a bug with the showmodaldialog, but this method works
clean.......

<script language=javascript>
function showmodalpopup() {
var cRetValue = window.showModalDialog("\PopUp.htm","","edge: raised;
dialogHeight: 40; dialogWidth: 65; center: yes; help: no; resizable: no;
status: no; scroll: no");
// Here we are simply calling the postback of a button with the ID
btnContinue from the aspx form......
if (cRetValue != null) {
__doPostBack('_ctl1$_ctl0$btnContinue','');
}
}
</script>

Joe Bonavita said:
I'm not too sure I know what you mean. When I call my GetDate function it
opens the calendar window and returns.

If I have the script return a value, how or where do I get this value in the
parent window?

James Radke said:
Joe,

You can do it one of two ways:

1.) Set a session variable in the calendar.aspx, since the popup window was
created from the original window, they will share the same session
variables.

or

2) When you close the popup window you can return a value to the javascript
which you can then set to a field on the web page..... Something like this
from the close function of the popup window:
Response.Write( said:
t>")

This will close the pop-up window, and pass a return value (here the text
'somevalue') back to the javascript as the result of the pop-up window
dialog.

The method chosen will depend on what processing you want to do immediately
after the date has been selected, if any.

Does that help?

Jim
sbScript.Append("window.opener.document.forms[0].lblArrivalPreivewDate.value
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top