Tuesday 24 April 2012

Modal Popup in SharePoint 2010

Hello,
To create a modal popup in sharepoint 2010, follow these steps:

1. Create a visual webpart project.
2. In .ascx, wrtie the following code:
   <script type="text/javascript">
   function OpenDialog(URL) {
    var NewPopUp = SP.UI.$create_DialogOptions();
    NewPopUp.url = URL;
    NewPopUp.width = 900;
    NewPopUp.height = 500;
    SP.UI.ModalDialog.showModalDialog(NewPopUp);
  }
 </script>
 <asp:Button ID="btnOpenDialog" Text="Open Dialog"  
      OnClientClick="javascript:OpenDialog('/_layouts/settings.aspx'); return false;" runat="server" />

3. Deploy the webpart.

When you add the webpart on a page, and click on "Open Dialog" button, we will be noticing the page is opening in a modal popup window.



No comments:

Post a Comment