Display a NewItem Form in a Modal Dialog in SharePoint 2010

Both Chaks’ post and Chris’ post helped.

I end up using Chris’ code as I needed a page redirect on form submit. So here is my code in my javascript file:

function portal_openModalDialog(){

var options = {

url:”/NoticeBoard/Lists/notices/NewForm.aspx?&IsDlg=1“,

dialogReturnValueCallback: DialogCallback

};

SP.UI.ModalDialog.showModalDialog(options);

}

function DialogCallback(dialogResult, returnValue){

window.location.href = “/Noticeboard/Pages/ThankYou.aspx”;

}

For the button to display the form, here is the code:

<a href=”#” onclick=”javascript:portal_openModalDialog();”>ADD NOTICE</a>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s