0

I have a drop down and it has 5 items . I need to show sharepoint modal popup based on the dropdown selected item on button click.

    <asp:DropDownListID="ddl1"runat="server"OnSelectedIndexChanged="ddl1_SelectedIndexChanged" AutoPostBack="true">
    <asp:ListItem>      SELECT     </asp:ListItem>
     <asp:ListItem>G P(No Contract Required)</asp:ListItem> 
     <asp:ListItem>NO Ct</asp:ListItem>
     <asp:ListItem>CONT</asp:ListItem>
     <asp:ListItem>TRA</asp:ListItem>
     <asp:ListItem>V-CON</asp:ListItem>
 <asp:linkButton ID="lnk" runat="server" Text="Add New Item" Font-Underline="false" >  </asp:linkButton> 

If select item is "CONT" then need to show sharepoint modal popup of one page ex:https://www.google.com else show the popup of the following url ex://https://www.gmail.com

on button click

can anyone help me on this

1 Answers1

0

You should call function OpenModalDialogTest() on your button click that would handle what item selected in dropdown like:

function OpenModalDialogTest(){
    $('select#yourId').change( function() {
        // this part runs every time the drop down is changed
       if($(this).val() == "CONT") // gets the selected value
         {
           //open sharepoint dialog using code below. 
         }
        else
         {
           //open sharepoint dialog using code below but change url parameter to https://www.gmail.com in your case. 
         }
    });
}

and open modal dialog with parameters like:

var options = {              
                url: 'https://www.google.com',
                tite: 'Google',
                allowMaximize: false,
                showClose: false,
                width: 800,
                height: 600,
};

              SP.UI.ModalDialog.showModalDialog(options);
Andrey Ungur
  • 2,360
  • 11
  • 9