driving me nuts - help me out!

Last post 10-16-2007 7:13 AM by NC01. 4 replies.

Sort Posts:

  • driving me nuts - help me out!

    11-10-2005, 7:02 AM
    • Loading...
    • yaron
    • Joined on 11-10-2005, 11:57 AM
    • Posts 1

    OK. Basically I have a scenario in which the user clicks the Send button - this fires off a function that sends an email, stores the info in the database etc. This process can take a long time due to the email having large attachments.

    I want to implement a progress bar, but I'm not too sure how to accomplish this. All the tutorials just show you how to paint a bar - but what I want to know is how to actually implement this. Where do I start this process, how will I find out the actual progress, how can I get it to run in the background whilst the real process is running?

    Can anyone point me in the right direction?

    Thanks!

  • Re: driving me nuts - help me out!

    11-10-2005, 9:02 AM
    • Loading...
    • stevenbey
    • Joined on 10-28-2002, 4:56 AM
    • United Kingdom
    • Posts 2,772
    There have been many, many threads on this subject. This search results page, from these forums, should provide an answer.
    Steven Bey

    Recursion: see Recursion
  • Re: driving me nuts - help me out!

    11-10-2005, 9:34 AM
    • Loading...
    • NC01
    • Joined on 08-26-2005, 3:33 PM
    • Posts 6,885
    • TrustedFriends-MVPs

    It's very tough to create a progress bar in an ASP.NET application (or any web app for that matter), because of the disconnected nature of a web app. Generally, a process is happening on the server, so the client-side is not even rendered yet.

    Here's a little control that I use that might help you out:

    The control:
    --------------

    using System;
    using System.Text;
    using System.Web.UI;

    namespace Tester
    {
     [ToolboxData("<{0}:BusyControl runat=server></{0}:BusyControl>")]
     public class BusyControl : System.Web.UI.WebControls.WebControl
     {
      // Found at:
      // C:\Program Files\Microsoft Office\CLIPART\PUB60COR\AG00011_.GIF
      private string m_ImageFilePath = @"AG00011_.GIF";

      public BusyControl()
      {
      }
      protected override void OnInit(EventArgs e)
      {
       base.OnInit(e);

       StringBuilder sbScript = new StringBuilder();

       sbScript.Append("\n");
       sbScript.Append("<div id='busyControlDiv' align='center' style='z-index:5000;'>\n");
       sbScript.Append("<br>\n");
       sbScript.Append("<br>\n");
       sbScript.Append("<br>\n");
       sbScript.Append("<br>\n");
       sbScript.Append("<br>\n");
       sbScript.Append(" <table align='center' bgcolor='ButtonFace' border='2' bordercolor='ButtonShadow' bordercolordark='ButtonShadow' ");
       sbScript.Append("  bordercolorlight='InactiveBorder' rules='none' cellpadding='10' cellspacing='0' width='30%'>\n");
       sbScript.Append("  <tr>\n");
       sbScript.Append("   <td width='100%' align='center' valign='center' nowrap>\n");
       sbScript.Append("    <font size='3' color='Black'>\n");
       sbScript.Append("     <b>Working...</b>\n");
       sbScript.Append("    </font>\n");
       sbScript.Append("    <br>\n");
       sbScript.Append("    <img src='" + this.m_ImageFilePath + "' border='0'>\n");
       sbScript.Append("   </td>\n");
       sbScript.Append("  </tr>\n");
       sbScript.Append(" </table>\n");
       sbScript.Append("</div>\n");

       this.Page.Response.Write(sbScript.ToString());
       this.Page.Response.Flush();
      }
      protected override void OnLoad(EventArgs e)
      {
       base.OnLoad(e);

       StringBuilder sbScript = new StringBuilder();

       sbScript.Append("\n");
       sbScript.Append("<script language=\"JavaScript\" type=\"text/javascript\">\n");
       sbScript.Append("<!--\n");
       // W3C DOM
       sbScript.Append("if ( document.getElementById )\n");
       sbScript.Append(" document.getElementById('busyControlDiv').style.display = 'none';\n");
       // IE 4
       sbScript.Append("else if ( document.all )\n");
       sbScript.Append(" document.all.busyControlDiv.style.display = 'none';\n");
       // NS 4
       sbScript.Append("else if ( document.layers )\n");
       sbScript.Append(" document.busyControlDiv.display = 'none';\n");

       sbScript.Append("//-->\n");
       sbScript.Append("</script>\n");
       
       this.Page.Response.Write(sbScript.ToString());
      }
     }
    }

    In the page to use it:
    -----------------------

    At the top of the aspx file add:
    <%@ Register TagPrefix="cc1" Namespace="Tester" Assembly="Tester" %>

    Between the <form> tags add:
    <cc1:BusyControl id="BusyControl1" runat="server"></cc1:BusyControl>

    In the CodeBehind, Page_Load event handler:
    private void Page_Load(object sender, System.EventArgs e)
    {
     // Here we just wait 10 seconds to emulate a lengthy process...
     TimeSpan waitTime = new TimeSpan(0, 0, 0, 10);
     System.Threading.Thread.Sleep(waitTime);

     // Indicate that the process is done...    
     this.Response.Write("The lengthy process has completed and the page has now fully loaded.");
    }

    NC...

  • Re: driving me nuts - help me out!

    10-16-2007, 3:13 AM
    • Loading...
    • sagarharale
    • Joined on 08-01-2007, 6:42 AM
    • Posts 3

     

    Hey I tried as u shown that ...............

    I have created on web control lib with name BusyControl and added that dll to my Application .....and next process of registering the control ...

    But when i m running that page it is giving error "File or assembly name Tester, or one of its dependencies, was not found." ... Did all the things ....

    Properly .... Plz help me out .... to find the answer

     
    Thanks

    Sagar  :)


     

     

  • Re: driving me nuts - help me out!

    10-16-2007, 7:13 AM
    • Loading...
    • NC01
    • Joined on 08-26-2005, 3:33 PM
    • Posts 6,885
    • TrustedFriends-MVPs

    "Tester" is the namespace name.
         using System;
         using System.Text;
         using System.Web.UI;

         namespace Tester
         {
              ...

    You'd have to change that to match your particular Project/Solution.

    This is such a basic thing that I'd also suggest that you read up on creating .NET applications in general and ASP.NET applications specifically. Some excellent tutorials can be found in the "Learn" option in the menu at the top of this page.

    NC...

Page 1 of 1 (5 items)