While working with SharePoint / JavaScript modal pop up you might encounter error "cannot read property 'showmodaldialog' of undefined". Here is simple solution for that.
Code Sample:
function OpenDocsDialog(url1) {
var options = {
url: url1,
dialogReturnValueCallback: myDialogCallback
};
SP.UI.ModalDialog.showModalDialog(options); // this line gives error.
}
Solution : We need to load "sp.js" file before calling above code. You can load "sp.js" file with below code sample:
ExecuteOrDelayUntilScriptLoaded(function () { //code }, "sp.js")
Full solutionExample :
function OpenDocsDialog(url1) {
var options = {
url: url1,
dialogReturnValueCallback: myDialogCallback
};
ExecuteOrDelayUntilScriptLoaded(function () {
SP.UI.ModalDialog.showModalDialog(options);
}, "sp.js")
}
Subscribe to:
Posts (Atom)
-
Recently I was working on sending mail using smtp server where I stuck on below error: IIS/SMTP - emails are stuck in mailroot/Queue ...
-
If you want to know which controlled fired post back at page load, here is some sample code. 1) for link button: string ctrlname = Page....
-
While working with SharePoint / JavaScript modal pop up you might encounter error "cannot read property 'showmodaldialog' of un...
