Loading...

Saturday, July 9, 2011

Modal Popup with Content Editor Webpart

Open the sharepoint Site
In Ribbon,Find Insert Link-->Select Webparts-->In Media and Content Category-->Select Content Editor Webpart.-->Add/Edit the webpart

In SP 2010, Select Contents in CEWP, Format--> Html Source in the ribbon,
Add the javacript code
<script type="text/javascript">
     function OpenDialog(URL) {
         var NewPopUp = SP.UI.$create_DialogOptions();
         NewPopUp.url = URL;
         NewPopUp.width = 700;
         NewPopUp.height = 350;
         SP.UI.ModalDialog.showModalDialog(NewPopUp);
     }
 script>

"javascript:OpenDialog(‘../_layouts/MyAppPage/MyPage.aspx’)"--To Make it Server relative.
So that Dialog box opens anywhere in site collection

7 comments:

Ciaranc said...

Does this work with SP 2007?

If not, is there an alternative way to use Modal Pop Ups?

Swati Jain said...

Hi Ciaranc,

You can use jquery /javascript modal popups .Add this code in content editor webpart in sp 2007 sites.
you can try referencing sp.js from sp 2010 machine .check if same script given in this blogpost works, in that case

Kiran Joshya said...

Great Article! Thanks for the nice collection of info...
SharePoint 2013 Training Institutes in Hyderabad

Manideep Agarwal said...

Great article ...Thanks for your great information, the contents are quiet interesting. I will be waiting for your next post.
SharePoint 2013 Online Training in Hyderabad

Rakesh Parval said...

Wooh this is very informative article. Thank you so much..!
SharePoint 2013 Developer Training in Hyderabad

Staygreen Academy said...

Information was good,i like your post.
Looking forward for more on this topic
SharePoint 2013 Administration Training in Hyderabad

Rekha Gunathilake said...

Awesome article! Works perfect! Thanks a lot! Cheers!