SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So I am using the Upload.aspx for doc lib with GUID in order to have Upload at a custom spot on a page. I think its the edit form that pops up right after you upload a document to add the metadata. This is great and what I need, however there is one little piece I need some help with. If I set the options for the dialog I am using with the Upload.aspx the width and height stick for the edit form that pops open after and either way it looks bad. I either make a ridiculously large dialog for the upload to accomodate the edit, or visa versa.

So I am guessing there is a way to handle that in the callback, just not really sure.

Here is basically what I am calling from an onclick:

function openDialog() {
   var dialogOptions = SP.UI.$create_DialogOptions();
   dialogOptions.url = "server/site/_layouts/Upload.aspx?List={GUID}&IsDlg=1";
   dialogOptions.width = 700  //works for the upload not for the edit
   dialogOptions.height = 185 //same as above; works for the upload
   dialogOptions.title = "My Title"
   dialogOptions.dialogReturnValueCallback = Function.createDelegate(null, CloseCallBack);
   SP.UI.ModalDialog.showModalDialog(dialogOptions); }

function CloseCallBack (result, returnValue) {
     if (result == SP.UI.DialogResult.OK) {
         // logic
     } else {
        // logic 

Is there someway to remedy this? thanks as always for you help guys! always appreciated.

share|improve this question
up vote 4 down vote accepted

So what you want to do is to change the size of the dialog when the upload.aspx is closed. Try this code

ExecuteOrDelayUntilScriptLoaded(function () {

 var dlg = window.parent.SP.UI.ModalDialog.get_childDialog();
 dlg.$Q_0(800, 800); //width, height

}, "sp.ui.dialog.js");

Also, if you want to size the dialog automatically without specifying the height and width, use this:

ExecuteOrDelayUntilScriptLoaded(function () {

    //calling autoSize method will extend modal dialog beyond the size of the page
    //calling this obfuscated method will trim the dialog back within the page boundaries.

}, "sp.ui.dialog.js");
share|improve this answer
@vardhaman....thanks! would i simply add the above inside the callback function (where the result is OK)? Or would this go with the initial function? I tried in both spots but can't seem to get it to work; perhaps I am just doing something wrong? – Justin Aug 15 '12 at 17:56
You will have to write this code on the EditForm.aspx which loads after the Upload.aspx has closed. Also, check out the updated code. – Vardhaman Deshpande Aug 15 '12 at 18:07 I could just use a CEWP and reference a text file with the above kind of thing? makes sense. thanks again for your help! – Justin Aug 15 '12 at 18:08
Or you could directly include the code in <script> tags on the page if you have access to SharePoint Designer. – Vardhaman Deshpande Aug 15 '12 at 18:10
works great! thanks for your help; greatly appreciated! – Justin Aug 15 '12 at 18:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.