Javascript Error When Uploading

Last post 03-31-2009, 12:53 AM by cutechat. 10 replies.
Sort Posts: Previous Next
  •  03-25-2009, 8:17 PM 50285

    Javascript Error When Uploading

    Error: no element found
    Source File: http://!!OURURL!!/CuteSoft_Client/CuteEditor/Dialogs/InsertImage.aspx?setting=!3wEWAgUFZW4tdXMFAyRhMQLSH48!3Zk5x1qyi9ktWIFhW8fm6&Theme=Office2003&&UseUploadModule=Dynamic&_Namespace=CuteEditor&_UploadID=InputFileImage_1238029838705_2&_UploadControlID=InputFile&ContextValue=!3wEWAQUOfi9VcGxvYWRlclRlbXCAxjPe4btc6dUBzycrZ72cqwWaSw!2!2&_MaxSizeKB=2000&_Addon=verify&_AddonGuid=1645451b-185e-4010-8763-a9f4a4a983ac
    Line: 1
     
    This was working properly a few days ago now we are unable to finish uploading an image.  It uploads successfully to the UploaderTemp Directory but just stops at 100%
    Filed under: ,
  •  03-25-2009, 8:26 PM 50286 in reply to 50285

    Re: Javascript Error When Uploading

    MARKA,
     
    Please download the latest build then try again.
     
    Keep me posted

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  03-25-2009, 8:28 PM 50287 in reply to 50286

    Re: Javascript Error When Uploading

    Just did that and no luck.
  •  03-25-2009, 8:38 PM 50289 in reply to 50287

    Re: Javascript Error When Uploading

    This is very important that we get this resolved.  This is driving a major website admin.  Please Advise how I can help debug this
  •  03-25-2009, 8:52 PM 50290 in reply to 50289

    Re: Javascript Error When Uploading

    Well...
     
    I figured it out.
     
    I wrote a http viewstate httpModules that moves the viewstate to the bottom of the page.
     
    this caused the error.
  •  03-25-2009, 8:58 PM 50291 in reply to 50290

    Re: Javascript Error When Uploading

    The question now is..... WHY?
     
    I need to be able to push the viewstate to the bottom of the page.  How can I do this and maintain functionality with the uploader?
  •  03-26-2009, 10:47 PM 50345 in reply to 50291

    Re: Javascript Error When Uploading

    Hi,
     
    Can you provide that module code so that we can make a test ?
     
    Regards,
    Terry
     
  •  03-27-2009, 3:35 PM 50394 in reply to 50345

    Re: Javascript Error When Uploading

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.IO;
    using System.Text;

    public class MarksMoveViewStateMod : IHttpModule
    {  

        void IHttpModule.Init(HttpApplication context)
        {
            // Add Event
            context.BeginRequest += new EventHandler(context_BeginRequest);
        }

        void context_BeginRequest(object sender, EventArgs e)
        {
            HttpApplication _HttpApp = sender as HttpApplication;
            if (_HttpApp.Request.Url.OriginalString.Contains(".aspx"))
            {
                _HttpApp.Response.Filter = new ViewstateFilter(_HttpApp.Response.Filter);
            }
        }

        private class ViewstateFilter : Stream
        {
            public ViewstateFilter(Stream TempStream)
            {
                _TmpStream = TempStream;
            }

            public override bool CanRead { get { return true; } }

            public override bool CanSeek { get { return true; } }

            public override bool CanWrite { get { return true; } }

            public override void Flush() { _TmpStream.Flush(); }

            public override long Length { get { return 0; } }

            public override long Position
            {
                get { return _position; }
                set { _position = value; }
            }
            public override int Read(byte[] buffer, int offset, int count) { return _TmpStream.Read(buffer, offset, count); }
            public override long Seek(long offset, SeekOrigin origin) { return _TmpStream.Seek(offset, origin); }
            public override void SetLength(long value) { _TmpStream.SetLength(value); }
            public override void Close() { _TmpStream.Close(); }
            private StringBuilder _DataBuffer = new StringBuilder();
            private Stream _TmpStream;
            private long _position;

            public override void Write(byte[] buffer, int offset, int count)
            {

                string html_part = System.Text.Encoding.Default.GetString(buffer);

                _DataBuffer.Append(html_part);

                // I bet this causes problems with something...  but No definitive way to test for this unless EOF is sent
                // No time to test....
                if (html_part.Contains("</html>"))
                {
                    string html = _DataBuffer.ToString();
                    html = html.Replace("~/", Utility.BASEURL);
                    int startPoint = html.IndexOf("<input type=\"hidden\" name=\"__VIEWSTATE\"");
                    // Can Add Other ASP.NEt *** here also
                    if (startPoint >= 0)
                    {
                        int endPoint = html.IndexOf("/>", startPoint) + 2;
                        string viewstateInput = html.Substring(startPoint, endPoint - startPoint);
                        html = html.Remove(startPoint, endPoint - startPoint);
                        int formEndStart = html.IndexOf("</form>") - 1;
                        if (formEndStart >= 0) { html = html.Insert(formEndStart, viewstateInput); }
                    }
                    byte[] outdata = System.Text.Encoding.Default.GetBytes(html);
                    _TmpStream.Write(outdata, 0, outdata.GetLength(0));
                }
            }
        }    

        void IHttpModule.Dispose()
        {
          
        }

    }

  •  03-27-2009, 3:37 PM 50395 in reply to 50394

    Re: Javascript Error When Uploading

    Utility.BASEURL just replace that with your ro0t application.  I use that too replace css directories when sub app points are used.
  •  03-30-2009, 9:22 PM 50490 in reply to 50394

    Re: Javascript Error When Uploading

    Any Update on this?
  •  03-31-2009, 12:53 AM 50496 in reply to 50490

    Re: Javascript Error When Uploading

    Hi,
     
    I have tested your code.
     
    The problem is that , your code output nothing if the content do not contains <html>
     
    So you'd better do this way :'
     
     
      public override void Close()
      {
       if (_DataBuffer.Length > 0)
       {
        byte[] outdata = System.Text.Encoding.Default.GetBytes(_DataBuffer.ToString());
        _TmpStream.Write(outdata, 0, outdata.GetLength(0));
       }

       _TmpStream.Close();
      }
     
     

       if (html_part.Contains("</html>"))
       {
        string html = _DataBuffer.ToString();
        html = html.Replace("~/", HttpContext.Current.Response.ApplyAppPathModifier("~/"));
        int startPoint = html.IndexOf("<input type=\"hidden\" name=\"__VIEWSTATE\"");
        // Can Add Other ASP.NEt *** here also
        if (startPoint >= 0)
        {
         int endPoint = html.IndexOf("/>", startPoint) + 2;
         string viewstateInput = html.Substring(startPoint, endPoint - startPoint);
         html = html.Remove(startPoint, endPoint - startPoint);
         int formEndStart = html.IndexOf("</form>") - 1;
         if (formEndStart >= 0) { html = html.Insert(formEndStart, viewstateInput); }
        }

        _DataBuffer.Length = 0;
        byte[] outdata = System.Text.Encoding.Default.GetBytes(html);
        _TmpStream.Write(outdata, 0, outdata.GetLength(0));
       }
     
     
    Regards,
    Terry
     
View as RSS news feed in XML