JavaScript Error: Ox4 is null

Last post 01-30-2009, 11:46 PM by cutechat. 1 replies.
Sort Posts: Previous Next
  •  01-30-2009, 1:19 PM 48238

    JavaScript Error: Ox4 is null

    Here is the scenario:
     
    A user can upload one Image.  Once the Image has been uploaded, I hide the Uploader.  If that image is deleted, I show the Uploader. 
     
    I receive the JavaScript error when an Image is uploaded, then deleted, and then the user attempts to upload another Image.
     
    Here is the code:
     
    <asp:SqlDataSource runat="server" ID="SpotlightDS">
        [...]
    </asp:SqlDataSource>
    <asp:ScriptManager ID="Scriptmanager1" runat="server">
    </asp:ScriptManager>
    <asp:WSFormView runat="server" ID="SpotlightFV" DataSourceID="SpotlightDS" DataKeyNames="ID" DefaultMode="Edit" OnItemUpdated="Redirect">           
        <InsertItemTemplate>
           [...]
          
                            <asp:UpdatePanel runat="server" ID="ImageUP">
                                <ContentTemplate>
                                    <dt><asp:Label runat="server" ID="ImageL" Text="Image*:" /></dt>
                                    <dd>
                                        <asp:PlaceHolder runat="server" ID="NoImagePH" Visible='<%# Eval("Image") == DBNull.Value %>'>
                                            <CuteWebUI:Uploader runat="server" ID="ImageCute" OnFileUploaded="ImageUploaded" InsertText="Upload Image" MultipleFilesUpload="false" MaxFilesLimit="0" OnInit="SetTempDirectory" >
                                                <ValidateOption AllowedFileExtensions="jpg,gif" MaxSizeKB="25600" />
                                            </CuteWebUI:Uploader>
                                        </asp:PlaceHolder>
                                        <asp:PlaceHolder runat="server" ID="ImagePH" Visible='<%# Eval("Image") != DBNull.Value %>'>
                                            <asp:Hyperlink runat="server" ID="PreviewImageHL" Text='<%# Eval("Image") %>' NavigateUrl='<%# "../media/" + Eval("Image") %>' Target="_blank" /> | <asp:LinkButton runat="server" ID="DeleteImageLB" Text="Delete" OnCommand="DeleteCommand" CommandName="Image" CommandArgument='<%# Eval("Image") %>' />
                                        </asp:PlaceHolder>
                                    </dd>                                                        
                                </ContentTemplate>
                            </asp:UpdatePanel>
          
           [...]
        </InsertItemTemplate>
     </asp:WSFormView>
     
     protected void ImageUploaded(object sender, UploaderEventArgs e)
        {
            string Sql = string.Empty;
            string Filetype = string.Empty;
            string Folder = string.Empty;
            string Folderpath = string.Empty;
            string Filename = string.Empty;

            Filetype = ((Uploader)sender).ID;
            Filename = System.IO.Path.GetFileName(e.FileName);

            if (Filetype.Contains("Image"))
            {
                Sql = "UPDATE Spotlights SET Image = @Upload WHERE ID = @SpotlightID;";
                Folder = "images/";
            }
            else if (Filetype.Contains("Thumbnail"))
            {
                Sql = "UPDATE Spotlights SET Thumbnail = @Upload WHERE ID = @SpotlightID;";
                Folder = "thumbnails/";
            }
            else if (Filetype.Contains("Video"))
            {
                Sql = "UPDATE Spotlights SET Video = @Upload WHERE ID = @SpotlightID;";
                Folder = "videos/";
            }

            Folderpath = MapPath("/");
            Folderpath = Folderpath.TrimEnd('""');
            Folderpath = Folderpath.Substring(0, Folderpath.LastIndexOf('""'));
            Folderpath += ConfigurationManager.AppSettings["UploadFolderPath"];
            Folderpath += Folder;

            using (SqlConnection SqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["SpotlightCS"].ConnectionString))
            using (SqlCommand SqlCmd = new SqlCommand("", SqlConn))
            {
                SqlConn.Open();
                SqlCmd.CommandText = Sql;
                SqlCmd.Parameters.Add("SpotlightID", SqlDbType.Int).Value = Request["id"];
                SqlCmd.Parameters.Add("Upload", SqlDbType.VarChar).Value = Folder + Filename;
                SqlCmd.ExecuteNonQuery();
            }

            e.CopyTo(Folderpath + Filename);
            e.Delete();

            
            SpotlightFV.DataBind();
        }
        
        protected void DeleteCommand(object sender, CommandEventArgs e)
        {
            string Sql = string.Empty;
            string Folder = string.Empty;
            string Folderpath = string.Empty;

            if (e.CommandName == "Image")
            {
                Sql = "UPDATE Spotlights SET Image = @Null WHERE ID = @SpotlightID;";
                Folder = "images/";
            }
            else if (e.CommandName == "Thumbnail")
            {
                Sql = "UPDATE Spotlights SET Thumbnail = @Null WHERE ID = @SpotlightID;";
                Folder = "thumbnails/";
            }
            else if (e.CommandName == "Video")
            {
                Sql = "UPDATE Spotlights SET Video = @Null WHERE ID = @SpotlightID;";
                Folder = "videos/";
            }

            Folderpath = MapPath("/");
            Folderpath = Folderpath.TrimEnd('""');
            Folderpath = Folderpath.Substring(0, Folderpath.LastIndexOf('""'));
            Folderpath += ConfigurationManager.AppSettings["UploadFolderPath"];
            //Folderpath += Folder;
            System.IO.File.WriteAllText([...]);

            using (SqlConnection SqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["SpotlightCS"].ConnectionString))
            using (SqlCommand SqlCmd = new SqlCommand("", SqlConn))
            {
                SqlConn.Open();
                SqlCmd.CommandText = Sql;
                SqlCmd.Parameters.Add("SpotlightID", SqlDbType.Int).Value = Request["id"];
                SqlCmd.Parameters.Add("Null", SqlDbType.VarChar).Value = DBNull.Value;
                SqlCmd.ExecuteNonQuery();
            }

            SpotlightFV.DataBind();
        }
     
    The JavaScript error is:
     
     Error: Ox4 is null
    Source File: https://wsdev.missouristate.edu/SpotLights/CuteWebUI_Uploader_Resource.axd?type=script&_ver=633683056557902511
    Line: 1
     
    I'm assuming it has something to do with how I toggle the placeholders.  Any ideas / suggestions?

  •  01-30-2009, 11:46 PM 48244 in reply to 48238

    Re: JavaScript Error: Ox4 is null

    Hi,
     
    Can you try the last version?
     
    I can't reproduce this error.
     
    Regards,
    Terry
View as RSS news feed in XML