Wrox Programmer Forums
|
ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 14th, 2009, 04:15 AM
Authorized User
 
Join Date: Nov 2008
Posts: 21
Thanks: 3
Thanked 0 Times in 0 Posts
Send a message via MSN to MonkeyMan666
Default Code order?

Hiya,

I have a chunk of code (see below) which on the click of a button makes a picture and label visible, then uploads a file then sends an email. It is uploading the file and sending the email before making the image visible. Do I need to refresh the page before doing anything with the file and email?

My code is:
Code:
string filename = fulUploader.FileName;
lblUploading.Visible = true;
imgRadio.Visible = true;
UploadFile(filename);
SendDownloadEmail();


The code for uploading the file and sending the email works fine, its just getting the image visible before doing anything else.

Thank you in advance

Andy
 
Old January 14th, 2009, 01:14 PM
Lee Dumond's Avatar
Wrox Author
 
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

Your code is firing in the correct order. The reason it appears as though it's not, is that you can't actually "see" that the image has been made visible until you get the response back from the post.

If you want it to work the other way around, you may want to consider controlling the visibility of the image and label from the client side using JavaScript.
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
 
Old January 14th, 2009, 08:45 PM
Friend of Wrox
 
Join Date: Dec 2008
Posts: 238
Thanks: 2
Thanked 20 Times in 19 Posts
Default

To improve user experience, it is better to have SendDownloadEmail() async - less response time.
 
Old January 14th, 2009, 08:48 PM
Friend of Wrox
 
Join Date: Dec 2008
Posts: 238
Thanks: 2
Thanked 20 Times in 19 Posts
Default

Not tested, but if you set visible to true in javascript, I think it will apear right the way...
 
Old January 15th, 2009, 06:21 AM
Authorized User
 
Join Date: Nov 2008
Posts: 21
Thanks: 3
Thanked 0 Times in 0 Posts
Send a message via MSN to MonkeyMan666
Default

I have got the visibility working through javascript but how do I go about calling the web methods in C# from javascript.
 
Old January 15th, 2009, 01:30 PM
Lee Dumond's Avatar
Wrox Author
 
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

Quote:
Originally Posted by MonkeyMan666 View Post
I have got the visibility working through javascript but how do I go about calling the web methods in C# from javascript.
It depends on how critical it is for the events to all happen in a series.

I was thinking you could still do the server side uploading and email by wiring the click event as you have been, and triggering the script from OnClientClick in the same button. This would be the easiest way to go and would make it appear as though the label/image visibility was happening first, though in reality both the client and server functions would be called at the same time.

If that's not cutting the mustard for you, following is an interesting article about calling a server side method using JavaScript:

http://www.azamsharp.com/Posts/92_A_...rameworks.aspx
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
 
Old January 15th, 2009, 02:31 PM
Friend of Wrox
 
Join Date: Dec 2008
Posts: 238
Thanks: 2
Thanked 20 Times in 19 Posts
Default

Quote:
Originally Posted by Lee Dumond View Post
I was thinking you could still do the server side uploading and email by wiring the click event as you have been, and triggering the script from OnClientClick in the same button.
I was thinking the same way. This actually matches the principle to separate view from data. His javascript mainly deals with view, for example set those to visible.





Similar Threads
Thread Thread Starter Forum Replies Last Post
ORDER BY Help U.N.C.L.E. SQL Server 2000 13 September 2nd, 2008 09:07 PM
Event order miltonsnider ASP.NET 2.0 Professional 0 February 9th, 2007 09:56 AM
Order of Code Generation Problem forfree ASP.NET 1.0 and 1.1 Basics 1 July 5th, 2006 09:48 PM
Stacking order keithc BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 2 February 26th, 2006 01:08 PM
document node order vs sort node order. ladyslipper98201 XSLT 2 June 5th, 2003 11:06 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.