Link to home
Start Free TrialLog in
Avatar of R8VI
R8VI

asked on

upload progress information from server real time asp.net, c#

hi,

I want to know how i can progress information for a server as i am doing a file upload and want to create a progress bar.

Thanks,

R8VI
Avatar of aibusinesssolutions
aibusinesssolutions
Flag of United States of America image

I've had good luck with the obout.com file upload progress bar.

http://www.obout.com/fup/index.aspx

The alternative would be to create your own upload form using an iFrame and javascript, which can be found here.

http://geekswithblogs.net/rashid/archive/2007/08/01/Create-An-Ajax-Style-File-Upload.aspx
Avatar of R8VI
R8VI

ASKER

see my problem is i dont really want to pay for one so might have toi try the other one lol
ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of R8VI

ASKER

thanks emoreau,

just wondering if you have used this component, and if so could you guide me as i have a file upload component that i use to upload my files this is the one provide within Visual studios so how would i integrate the progress bar with that component

Thanks

R8VI
I have used it more then 2 years ago. The web site as a couple of example for you to quickly integrate it into your own application. You won't have to use the file upload component that is provided with VS anymore.
Avatar of R8VI

ASKER

oh ok so could you give me a code example if possible
There is a user manual on the Neat Upload site with code examples.

http://www.brettle.com/NeatUpload-1.3/dotnet/docs/Manual.html#3.2.Using NeatUpload with the Visual Studio Web Form Designer|outline
Avatar of R8VI

ASKER

hi,

thanks for all the help so far. now i am using neatupload I have the following code
aspx page

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register Assembly="Brettle.Web.NeatUpload" Namespace="Brettle.Web.NeatUpload"
    TagPrefix="Upload" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>

</head>
<body>
    <form id="form1" runat="server">
    <div>
        <Upload:InputFile ID="inptfileupload" runat="server" />
    </div>
          <script type="text/javascript">
            function UpdateUrlsAndDisplayProgress()
            {
                  var inlineProgressBar = document.getElementById("prgbar");
                  var nuf = NeatUploadForm.prototype.GetFor(inlineProgressBar, '<%= prgbar.PostBackID %>');
                  var link1 = document.getElementById("link1");
                  var link2 = document.getElementById("link2");
                  var link3 = document.getElementById("link3");
                  link1.href = nuf.ChangePostBackIDInUrl(link1.href, "NeatUpload_PostBackID");
                  link2.href = nuf.ChangePostBackIDInUrl(link2.href, "NeatUpload_PostBackID");
                  link3.href = nuf.ChangePostBackIDInUrl(link3.href, "NeatUpload_PostBackID");
                  NeatUploadPB.prototype.Bars['prgbar'].Display();
            }
            </script>
    <Upload:ProgressBar ID="prgbar" runat="server" />
    <p>
        &nbsp;</p>
    <asp:Button ID="btnsubmit" runat="server" Text="Button"  />
    </form>
    </body>
</html>


c# code

using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Web.SessionState;
using Brettle.Web.NeatUpload;

public partial class _Default : System.Web.UI.Page
{
    protected HtmlGenericControl uploadedFilePre;
            
            protected override void OnInit(EventArgs e)
            {
                  InitializeComponent();
                  base.OnInit(e);
            }
            
            private void InitializeComponent()
            {
                  this.Load += new System.EventHandler(this.Page_Load);
            }
            
            private void Page_Load(object sender, EventArgs e)
            {
            btnsubmit.Click += new System.EventHandler(this.btnsubmit_Click);
                  if (!IsPostBack && Request.Params["processing"] == "true")
                  {
                        DoProcessing();
                  }
            }
            
            private void DoProcessing()
            {
            ProgressInfo progress = prgbar.ProcessingProgress = new ProgressInfo(5000, "Units");
            //ProgressInfo progress = inlineProgressBar.ProcessingProgress = new ProgressInfo(5000, "Units");
                  for (int i = 1; i <= 5000; i++)
                  {
                        System.Threading.Thread.Sleep(1);
                        progress.Value = i;
                  }
                  progress.Text = "Processing Complete";
            }

        private void btnsubmit_Click(object sender, EventArgs e)
            {
                  DoProcessing();
                  uploadedFilePre.InnerText = "";
            if (inptfileupload.HasFile)
                  {
                uploadedFilePre.InnerText += "  Name: " + inptfileupload.FileName + "\n";
                uploadedFilePre.InnerText += "  Size: " + inptfileupload.ContentLength + "\n";
                uploadedFilePre.InnerText += "  Content type: " + inptfileupload.ContentType + "\n";
                  }
            }
      }

 but keep getting error

Object reference not set to an instance of an object. on line

ProgressInfo progress = prgbar.ProcessingProgress = new ProgressInfo(5000, "Units");

please help

Thanks,

R8VI
where do you get the error?
Avatar of R8VI

ASKER

hi

i get the error on the following line

ProgressInfo progress = prgbar.ProcessingProgress = new ProgressInfo(5000, "Units");

error is

Object reference not set to an instance of an object. on line