I have a custom list, and I want to create a direct link on the home page which points directly to adding a new item aka NewForm.aspx

So, I edited the page and add a link i.e. "Click Here" => (http://SharePointSite/Lists/WebEvents/NewForm.aspx)

But this link redirects to a new page which has the new form! I don't want that!

I want that if user clicks on "Click Here", then, The NewForm.aspx opens in Modal Dialog. I read that there is a way to accomplish this by using SP.UI.ModalDialog.showModalDialog("URL"); but how can I add the page? The link web part nor the hyperlink on the page will not accept that.

Could you please guide me ?

I tried <input type="button" value="Register" name="Go" onclick="SP.UI.ModalDialog.showModalDialog("http://SharePointSite/Lists/WebEvents/NewForm.aspx");" />

But it didn't work, besides, I wish to have the link as a text and not a button!

4 Answers 4


very close but you can simply use a bit of html and javascript:

<a onclick="javascript:SP.UI.ModalDialog.showModalDialog("http://SharePointSite/Lists/WebEvents/NewForm.aspx");return false;" href="">Display Item </a>

above explained:

Html part is the ' ' tag. this is for putting html links on a page:


For the javascript part we use onclick event (when a user clicks the hyperlink link). Within the quote marks you denote that your using javascript by the term javascript: once you have that part you can use any function or direct javascript code you want like doing an alert/messagebox alert("hello");. Most important is that you use return false; so that the onclick event is not expecting a value to postback that will refresh the page. the default href can be kept blank as we dont need to use it but is needed due to html requiring it so setting it to blank is more than enough "" .


Try to use the following code within a Script Editor / Content Editor:

function openDialog(pageUrl) { 
var options = {
    url: pageUrl,
    title: 'Title of the Dialog',
    allowMaximize: false,
    showClose: true,
    width: 500,
    height: 500
SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);       

<a href="#" onclick="openDialog('http://SharePointSite/Lists/WebEvents/NewForm.aspx');">New Form</a>

Note :

  • To show Maximize button set allowMaximize: true,


enter image description here

Check also the detail steps that matched with your situation at Open a link via Modal Dialog in SharePoint


Try the below code. I tried in content editor webpart and it works. enter image description here


Have you tried something like this?

<p><a href="#" onclick="OpenPopUpPageWithTitle('/sites/.../Lists/TestList/NewForm.aspx',null,500,250,'Add new Item')">New Item</a></p>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.