Sometimes we need to load a div in modal popup instead of a page. Following is an example code that we can use in such scenarios.
In this scenario I use a modal popup to load file upload control in the same page.
- function Opendialog(ctType) {
- SP.SOD.executeOrDelayUntilScriptLoaded(function () {
- var element = document.createElement('div');
- element.innerHTML = '<input type="file" id="documentUpload" accept="*" /><input id="btnUpload" type="button" value="Upload" onclick="UploadFile(\'' + ctType + '\')"; />';
- SP.UI.ModalDialog.showModalDialog({
- html: element,
- title: 'Document Upload',
- allowMaximize: false,
- showClose: true,
- dialogReturnValueCallback : Function.createDelegate(null, CloseCallback),
- autoSize: true
- });
- }, "SP.js");
- }
- function CloseCallback(result, target) {
- location.reload(true);
- }
No comments:
Post a Comment