donderdag 15 november 2012

How to use SharePoint’s default modal popup from code behind?

A while ago I needed to create a shopping basket. When you click on an item in that basket it would be nice if that item opens in a modal popup. But how can you access the default SharePoint modal popup dialog if it isn’t in your masterpage?

I used following code:

public static class Helper
    public static string GetDialogURL(string url, bool refreshOnClose, double width, double height)
        string str = string.Concat(new object[]
            "SP.UI.ModalDialog.showModalDialog({ url:'",
			"',tite: 'Move Documents',allowMaximize: true ,showClose: true,width:",
        if (refreshOnClose)
            str += ",dialogReturnValueCallback: function(dialogResult){SP.UI.ModalDialog.RefreshPage(dialogResult)}";
        str += "});";
        return str;
    public static string GetDialogURL(string url)
        return Helper.GetDialogURL(url, true, 700.0, 800.0);

Geen opmerkingen:

Een reactie posten