Solved

How to open SharePoint form in modal popup?

Posted on 2013-02-04
3
2,247 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you create your solutions on SharePoint sooner or later you will come upon a request to set  permissions of the item depending on some of the item's meta-data - the author, people assigned as approvers, divisions, categories etc. The most natu…
There is one common problem that all we SharePoint developers share: custom solution deployment. This topic can't be covered fully in this short article, so all I want to do in this one is to review it from a development-to-operations perspectiv…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

785 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