Pages

Monday, September 10, 2012

SharePoint - Link to new item

One of our customers wanted to show a link that opened the new item form dialog. This is the code you have to use:

< script type="text/javascript" >
var options = {
url: "/site/Lists/ListName/newform.aspx",
    title: "Open newform.aspx",
    allowMaximize: true,
    showClose: true,
    width: 625,
    height: 525,
    dialogReturnValueCallback: silentCallback};
function open() {SP.UI.ModalDialog.showModalDialog(options);}
function silentCallback(dialogResult, returnValue) {
}
function refreshCallback(dialogResult, returnValue) {
  SP.UI.Notify.addNotification('Operation Successful!');
  SP.UI.ModalDialog.RefreshPage(SP.UI.DialogResult.OK);
}
</script><a href="javascript:open()">Display instruction here</a> <a href="javascript:open()"></a>

You have to change the following:

url: "/site/Lists/ListName/newform.aspx"
Add the URL of the newform.aspx

title: "Open newform.aspx", 
You can add a title here. This won't effect the code.

Display instruction here
This is the text the end users will see.


source
http://social.technet.microsoft.com/Forums/en-US/sharepoint2010customization/thread/bf83bebf-fe73-47e2-94ab-7ea70bdb8149/



0 replies:

Post a Comment