0

I have an aspx page, which contains a file upload control, which has an onClientClick method which triggers a javascript method to pop out a modal window informing the user to wait:

<table style="width: 100%">
  <tr>
    <td class="bold"> 
       Project Attachments
    </td>
  </tr>
  <tr>
    <td>
      <asp:FileUpload ID="FU_ProjectAttachment" runat="server" Width="80%" />
    </td>
  </tr>
  <tr>
    <td>
      File Title: &nbsp;&nbsp;
      <asp:TextBox ID="TXT_FileTitle" Width="200px" runat="server"></asp:TextBox>
    </td>
  </tr>
  <tr>
     <td>
      File Type: &nbsp;
      <asp:DropDownList ID="DDL_FileType" runat="server" Width="203px">
      </asp:DropDownList>
     </td>
  </tr>
  <tr>
     <td>
        <div style="float: right;">
       <asp:Label ID="LBL_UploadError" runat="server" Visible="false" Style="color: Red"></asp:Label>&nbsp;
        <asp:Button ID="BTN_Upload" runat="server" Text="Upload" OnClick="BTN_Upload_Click" OnClientClick="javascript:showWaitScreen();" />
        </div>
        <div style="padding-top: 10px">
         <asp:HyperLink ID="HYP_DocTemplates" runat="server" Target="_blank" ToolTip="Opens Document Templates Page In New Tab"                           CssClass="sideLabels">View Document Templates</asp:HyperLink>
        </div>
       </td>
     </tr>
</table>

The JavaScript is at the top

<script type="text/javascript">
var waitDialog;
function showWaitScreen() {
    window.parent.eval("waitDialog = SP.UI.ModalDialog.showWaitScreenWithNoClose('Please Wait', 'Uploading...', 76, 330);");
}
function CloseWaitForm() {
    if (waitDialog != null) {
        waitDialog.close(0);
        waitDialog = null;
        location.reload();
    }
}
ExecuteOrDelayUntilScriptLoaded(ShowDialog, "sp.ui.dialog.js");

What is really confusing me is that when I run this from visual studio on my local machine to debug, it works, the modal dialog appears, however when I come to publish it onto the server, it doesn't work and no modal dialog appears on my sharepoint page. I have ran the IE javascript profiler and I get an error:

SCRIPT5007: The value of the property 'CloseWaitForm' is null or undefined, not a Function object

Any ideas?

Update:

From playing around trying to fix this, I've came to the conclusion that it is related to the style attached in SharePoint Designer, when using the v4.master, this modal dialog launches fine (this explains why it worked when on my local machine as it also had the v4.master) however when using the minimal.master style the modal dialog will not work and this is what I have been using on the server; I'm no closer to finding a solution though.

  • Is the JavaScript contained right on the web page or in a separate file? Also, is CloseWaitForm being called somewhere? The only reference to it in the code provided is where it is declared. – Hutch Nov 26 '13 at 19:26
  • sorry, yes the javascript is on the same web page as the file upload and CloseWaitForm is called in the C# code at the end of the upload operation: ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "CloseWaitForm", "CloseWaitForm();", true); – Jacob Nov 27 '13 at 7:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.