We have been using the Modal Dialogs for a long time. But, for a new project, created a SitePage using designer and tried to use the ModalDialog using Javascript. I thought, it’s a straight forward as we have used the modal dialog for a long time.
function OpenDocTopicPopup(bookcaseTopic) {
var options = {
url: '/pages/MyPage.aspx,
title: ‘TEst’,
allowMaximize: false,
showClose: true,
width: 1200,
height: 500,
dialogReturnValueCallback: Function.createDelegate(null, function (result, returnValue) {
if (result == SP.UI.DialogResult.OK) {
OpenDocTopicPage(returnValue);
}
})
};
SP.UI.ModalDialog.showModalDialog(options);
}
function OpenDocTopicPage(returnValue) {
window.location.href = window.location.href + "/" + returnValue;
}
When I try to execute this, met with a strange exception like “hiddenButtonValueBeforeDialog is undefined” from the SP.UI.Dialog.JS file. After some googling, found the answer and thought of documenting in our forum as well.
Solution:
It’s a straight forward. Add the below Tag on your ASPX.
<script type="text/javascript" src="/_layouts/15/ScriptResx.ashx?name=sp.res&culture=en-us"></script>
Happy Coding,
Sathish Nadarajan.
Leave a comment