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. Advertisements

  2. Joe Bonavita

    Joe Gass Guest

    Joe Gass, Nov 17, 2003
    #2
    1. Advertisements

  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

     
    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?

     
    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>

     
    James Radke, Nov 17, 2003
    #5
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.