Automatically open popup from a method

Last post 05-27-2008 8:11 AM by NC01. 8 replies.

Sort Posts:

  • Automatically open popup from a method

    05-26-2008, 7:48 AM
    • Participant
      1,104 point Participant
    • nixor
    • Member since 03-23-2003, 1:19 PM
    • Posts 617

    How Can I open a popup from a IndexChangedEvent

    I've tried with

     

           protected void ddl_NV_Cliente_RichiestaContattoCommerciale_SelectedIndexChanged(object sender, EventArgs e)
            {
                if(ddl_NV_Cliente_RichiestaContattoCommerciale.SelectedValue == "Richiamare")
                {
                    string url = "window.open('AgendaPopup.aspx?IDOwner=" + IDOwner.ToString() + "','Dettaglio','width=500,height=500, menubar=no, scrollbars=yes, resizable=yes');";
                    this.Page.ClientScript.RegisterStartupScript(this.GetType(),"openPopup", url,true) ;
                      }
            }

     

    but my solution doesn't works

     

  • Re: Automatically open popup from a method

    05-26-2008, 8:02 AM
    • Member
      595 point Member
    • jsharratt
    • Member since 08-10-2004, 2:14 PM
    • West Midlands, UK
    • Posts 97

    *bad advice, cheers for the pointer*


    Jon Sharratt

     

  • Re: Automatically open popup from a method

    05-26-2008, 8:13 AM
    • Participant
      1,104 point Participant
    • nixor
    • Member since 03-23-2003, 1:19 PM
    • Posts 617

    Thanks for help me

    I obtain this error

    Sys.Web.Forms.PageRequestManagerParserErrorException: The message receviced from the server could not be parsed.
    Common causes for this error are when the responses is modificed by calls to Response.Write(), response filters, HttpModules or server trace is enabled.

    Details: Error parsing near '<script type='text/j'

     

    Note: I use ajax toolkit in this page (included by a master page)

    Thanks

  • Re: Automatically open popup from a method

    05-26-2008, 8:36 AM
    • All-Star
      20,666 point All-Star
    • A1ien51
    • Member since 05-06-2005, 6:46 PM
    • MD USA
    • Posts 3,799

    Is the pop up blocker blocking your inital code? When you view the source code of the page in the browser are you seeing your JavaScript code?

     Eric

  • Re: Automatically open popup from a method

    05-26-2008, 8:40 AM
    • Participant
      1,104 point Participant
    • nixor
    • Member since 03-23-2003, 1:19 PM
    • Posts 617

    I dont' see the popup blocker message

     in the source code I can't see the JS

     I've searched the text "AgendaPopup" but I can't find reference

    in the DDL code I see this:

     

             <select name="ctl00$Content$ucAnagrafica$ddl_NV_Cliente_RichiestaContattoCommerciale" onchange="javascript:setTimeout('__doPostBack(\'ctl00$Content$ucAnagrafica$ddl_NV_Cliente_RichiestaContattoCommerciale\',\'\')', 0)" id="ctl00_Content_ucAnagrafica_ddl_NV_Cliente_RichiestaContattoCommerciale" class="Text11">
                    <option selected="selected" value=""></option>
                    <option value="Si">Si</option>
                    <option value="Richiamare">Richiamare</option>
                    <option value="NN">Non interessato</option>

                </select

     

  • Re: Automatically open popup from a method

    05-26-2008, 10:56 AM
    • Participant
      1,104 point Participant
    • nixor
    • Member since 03-23-2003, 1:19 PM
    • Posts 617

    Nobody Can Help me??? :-((((( 

  • Re: Automatically open popup from a method

    05-26-2008, 1:28 PM
    • All-Star
      75,939 point All-Star
    • NC01
    • Member since 08-26-2005, 7:33 PM
    • Posts 14,161
    • TrustedFriends-MVPs

    jsharratt: NEVER use Response.Write to output JavaScript as it places it before the page tags.

    nixor: What error do you get as your code worked for me.

    NC...

  • Re: Automatically open popup from a method

    05-26-2008, 3:01 PM
    • Participant
      1,104 point Participant
    • nixor
    • Member since 03-23-2003, 1:19 PM
    • Posts 617

    NC01:
    nixor: What error do you get as your code worked for me.
     

     

    ??? what do you mean? 

  • Re: Automatically open popup from a method

    05-27-2008, 8:11 AM
    Answer
    • All-Star
      75,939 point All-Star
    • NC01
    • Member since 08-26-2005, 7:33 PM
    • Posts 14,161
    • TrustedFriends-MVPs

    nixor:

    ??? what do you mean? 

    I mean that the code worked for me. What are we doing different?

    This is what I did with no problems:

    aspx file:

    <asp:DropDownList id="DropDownList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
     <asp:listitem value="">Select one</asp:listitem>
     <asp:listitem value="Si">Si</asp:listitem>
     <asp:listitem value="Richiamare">Richiamare</asp:listitem>
     <asp:listitem value="NN">Non interessato</asp:listitem>
    </asp:DropDownList>

    aspx.cs file:

    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
     if ( DropDownList1.SelectedValue == "Richiamare" )
     {
      int IDOwner = 123;
      ClientScriptManager clientScriptManager = Page.ClientScript;

      string javaScript =
       "window.open('AgendaPopup.aspx?IDOwner=" + IDOwner.ToString() + "','Dettaglio','width=500,height=500, menubar=no, scrollbars=yes, resizable=yes');";

      javaScript = "<script type=text/javascript>" + javaScript + "</script>";

      clientScriptManager.RegisterStartupScript(this.GetType(), "openPopup", javaScript) ;
     }
    }

    Of course, if you are using AJAX (I don't see why if you're setting AutoPostBack on the control) you would need to replace the ClientScriptManager object with a ScriptManager object.

    NC...

Page 1 of 1 (9 items)