0

I am making a CRUD list item Page.

When I add or edit list item, I want to load those page as a Modal popup.

For now I just use redirect and move to another page.

And I heard that use SP.UI.ModalDialog option, but I don`t know how to use it.

My Code is below, Please somebody help me.

protected void lnkbtnAdd_Click(object sender, EventArgs e)
{
   string siteUrl = SPContext.Current.Web.Url;
   string listBaseUrl = ddlList.SelectedItem.Text;
   string listUrl = listBaseUrl.Replace("/sites/dev/", "");

   Response.Redirect(string.Format(siteUrl + "/_layouts/15/ListItemControl/AddNewItem.aspx?parm={0}", listUrl));
}

2 Answers 2

1
 function openDialog(pageURL, aTitle, callback) 
{
        if (callback == null || typeof callback == 'undefined')
            callback = callbackOpenDialog;
        //Create dialog options
        var diagOptions = {
            url: itemPath,
            title: aTitle,
            allowMaximize: true,
            showClose: true,
            height: 500,
            dialogReturnValueCallback: callback
        };
        //Show Dialog
        SP.UI.ModalDialog.showModalDialog(diagOptions);

    }

In above function you need to pass pageURL and title whatever you want to display. Please make sure that sp.js load before this function run.

0

You can use OOTB function

OpenPopUpPage('dialog url here', function(sts,data) { 
 // sts could be 0(if closed or clicked cancel on the dialog box) or 1(if you click save or OK)
 //data contains data returned from popup
 //code you want to execute after you close dialog. if not required replace this function with null
},width,height);

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.