popup calendar HELP!!

Discussion in 'ASP .Net Web Controls' started by Joe Bonavita, Nov 16, 2003.

  1. Joe Bonavita

    Joe Bonavita Guest

    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
     
    Joe Bonavita, Nov 16, 2003
    #1
    1. Advertising

  2. Joe Bonavita

    Joe Gass Guest

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

    "Joe Bonavita" <JBonavita_@_caminus.com> wrote in message
    news:%...
    >
    > 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
    >
    >
     
    Joe Gass, Nov 17, 2003
    #2
    1. Advertising

  3. Joe Bonavita

    James Radke Guest

    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" <> wrote in message
    news:...
    > You could try this pop up calendar control instead
    > http://www.excentricsworld.com/customcontrols.aspx?id=7
    >
    > "Joe Bonavita" <JBonavita_@_caminus.com> wrote in message
    > news:%...
    > >
    > > 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
    > >
    > >

    >
    >
     
    James Radke, Nov 17, 2003
    #3
  4. Joe Bonavita

    Joe Bonavita Guest

    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" <> wrote in message
    news:%23lk%...
    > 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" <> wrote in message
    > news:...
    > > You could try this pop up calendar control instead
    > > http://www.excentricsworld.com/customcontrols.aspx?id=7
    > >
    > > "Joe Bonavita" <JBonavita_@_caminus.com> wrote in message
    > > news:%...
    > > >
    > > > 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
    > > >
    > > >

    > >
    > >

    >
    >
     
    Joe Bonavita, Nov 17, 2003
    #4
  5. Joe Bonavita

    James Radke Guest

    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" <JBonavita_@_caminus.com> wrote in message
    news:Obaz0%...
    > 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" <> wrote in message
    > news:%23lk%...
    > > 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" <> wrote in message
    > > news:...
    > > > You could try this pop up calendar control instead
    > > > http://www.excentricsworld.com/customcontrols.aspx?id=7
    > > >
    > > > "Joe Bonavita" <JBonavita_@_caminus.com> wrote in message
    > > > news:%...
    > > > >
    > > > > 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
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
     
    James Radke, Nov 17, 2003
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Saravana
    Replies:
    0
    Views:
    497
    Saravana
    Jul 11, 2003
  2. Shevek
    Replies:
    3
    Views:
    6,100
    Shevek
    Jun 23, 2004
  3. Shevek
    Replies:
    0
    Views:
    414
    Shevek
    Jun 23, 2004
  4. Parthiv Joshi
    Replies:
    1
    Views:
    767
    Samuel L Matzen
    Jul 6, 2004
  5. Jens Peter Hansen
    Replies:
    7
    Views:
    575
    Randy Webb
    Jun 19, 2004
Loading...

Share This Page