OK, so maybe others have figured this out, but if so, they haven't written about it. Wanted to use the JQuery Progressbar to display progress results for a long ASP.NET Process.
First thing was to download a theme from the ThemeRoller site, http://jqueryui.com/themeroller/, and add the jquery library to my project.
Next, you must create a class to process the status of a ThreadStart Result in ASP.NET. For details on doing this, you can read the Microsoft Documentation, located at: .
Next, you will need two pages, one for creating the long process, one for showing the progress of the item.
The majority of the work can be found in the sample code, found at: http://www.joshuablackstone.com/Examples/LongProcess.zip, but the key for me was how to show the progress in the progress bar. First, create your div, such as:
<div class="progress" rel="0" runat="server" id="progressBar"></div>, and then the code to post the value to the progress bar is set with this function:
function pageLoad(sender, args) {
if (args.get_isPartialLoad()) {
$("div.progress").each(function () {
var element = this;
$(element).progressbar({
value: parseInt($(element).attr("rel"))
});
});
}
}
The reason for the section (if (args.Get_isPartialLoad)) is because an update panel is triggering a timer every two seconds to get the latest value from the threadstart.
So then, you run the process, which sends the user to the progress page, where they will see a jquery themed progress bar showing progress for the long process, and redirects to a page of your choice when complete.
Cool.
Showing posts with label C#. Show all posts
Showing posts with label C#. Show all posts
Thursday, December 1, 2011
Using JQuery ProgressBar with Long ASP.NET Process
Posted by Joshua Blackstone at 10:50 AM 0 comments
Thursday, June 17, 2010
C# vs VB - The debate continues...
Just getting my feet wet with C#, after being a VB developer for awhile, realizing that C# is getting all of the jobs. With that being said, have run into a few difficulties in converting over, and I'll list a couple here, to be added to as I go along. Consider this a newbie's version of headaches you may face when switching to C#...
- In VB, if you want to locate an element inside of a control, you would use:
Dim control as CONTROLTYPE = CType(CONTAINER.FindControl("ControlID"), CONTROLTYPE)
In C#, you would write the same expression as:
CONTROLTYPE control = (CONTROLTYPE)CONTAINER.FindControl("ControlID"); - In VB, if you want to place an IIf statement inside of a Label Control, you're free to do so. Simply use
<%#IIf(Convert.ToString(EXPRESSION)=Something, True, False)%>
However, when you attempt to use this in C#, you will get an error, as IIf isn't recognized.
Here's the fix:
<%# (Convert.ToString(EXPRESSION) == Something ? True : False)%>. - Of Course, & is not recognized, it is replaced by +.
- I know when I was creating a VB Side HTML Message, or if I was creating a very long string, I would use '& vbCrLf _'. However, in C#, this changes a bit. Declare your String, and append it just as you would in JS. Example?
string A = "";
A += "This is a string ";
A += " and the second line of the string...";
I will modify this as I go, but if you are like me, and have done VB this whole time, I would recommend taking any current sites you have done, and redo them from scratch in C#. Get Hung Up? Use THIS as a last resort, it's a pretty good tool.
Good Luck!
Subscribe to:
Posts (Atom)