Solved

How to open SharePoint form in modal popup?

Posted on 2013-02-04
3
2,153 Views
Last Modified: 2013-05-08
I have a custom list with 3 content types. I would like to create a page with 3 buttons linked to NewForm for each content type. I would like the forms to open in modal dialogs. What is the easiest way to accomplish this for a non-programmer? I have seen some instructions online how to do modal dialogs with JavaScript but I need some help to walk me through how it should be done in my scenario.
0
Comment
Question by:MisUszatek
  • 2
3 Comments
 
LVL 44

Expert Comment

by:Rainer Jeschor
ID: 38852812
Hi,

probably the following should work:
<script type="text/javascript">
function OpenPopup(contenttypeid) {
	var url = "../lists/YourCustomList/NewForm.aspx?ContentTypeId=";
    var options = {
        url: url + contenttypeid,
        title: 'Add a new item',
        allowMaximize: false,
        showClose: true,
        width: 600,
        height: 500,
        dialogReturnValueCallback: refreshCallback
    }
    SP.UI.ModalDialog.showModalDialog(options);
}
</script>
<input type="button" text="New Content Type x" onclick="javascript:OpenPopup('0xYOURCONTENTTYPEIDofX');" />
<input type="button" text="New Content Type y" onclick="javascript:OpenPopup('0xYOURCONTENTTYPEIDofY>');" />

Open in new window



Just adjust the path to your list and the content type ids.

HTH
Rainer
0
 

Author Comment

by:MisUszatek
ID: 38853324
Can you please provide some more instructions how/where to add the script/code to a SharePoint page?
0
 
LVL 44

Accepted Solution

by:
Rainer Jeschor earned 400 total points
ID: 39061466
Hi,
sorry I missed your last comment.
Either you add the lines directly on the page using SharePoint designer OR you store the text inside of a text file (should be extension .txt), upload the file to a SharePoint document library and then add a Content Editor Web Part to that page and configure the web part to use the above uploaded text file as source.

I mostly prefer solution 2, because I do not always have access to SharePoint designer. Therefore I create a central Content Asset library (its just a document library) and I upload all texts, scripts ... to that library.

HTH
Rainer
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Note:  There are two main ways to deploy InfoPath forms:  Server-side and directly through the SharePoint site.  Deploying a server-side InfoPath form means the form is approved by the Administrator, thus allowing greater functionality in the form. …
When installing SharePoint 2010 RTM I came across a strange error, I was getting timeouts during the installation. I searched the web and found the best solution to be found here (http://social.msdn.microsoft.com/Forums/en-US/sharepoint2010genera…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now