Solved

How to open SharePoint form in modal popup?

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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Pimping Sharepoint 2007 without Server-Side Code Part 1 One of my biggest frustrations with Sharepoint 2007 in the corporate world is that while good-intentioned managers lock down the more interesting capabilities of Sharepoint programming in…
We had a requirement to extract data from a SharePoint 2010 Customer List into a CSV file and then place the CSV file into a directory on the network so that the file could be consumed by an AS400 system. I will share in Part 1 how to Extract the Da…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

829 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