Re: Javascript Error When Uploading

  •  03-31-2009, 12:53 AM

    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 Complete Thread