Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old January 14th, 2009, 03:15 AM
Authorized User
 
Join Date: Nov 2008
Location: Manchester, , United Kingdom.
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
  #2 (permalink)  
Old January 14th, 2009, 12:14 PM
Lee Dumond's Avatar
Wrox Author
Points: 4,942, Level: 29
Points: 4,942, Level: 29 Points: 4,942, Level: 29 Points: 4,942, Level: 29
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2008
Location: Decatur, IL, USA.
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(); 
}
  #3 (permalink)  
Old January 14th, 2009, 07:45 PM
Friend of Wrox
 
Join Date: Dec 2008
Location: , , .
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.
  #4 (permalink)  
Old January 14th, 2009, 07:48 PM
Friend of Wrox
 
Join Date: Dec 2008
Location: , , .
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...
  #5 (permalink)  
Old January 15th, 2009, 05:21 AM
Authorized User
 
Join Date: Nov 2008
Location: Manchester, , United Kingdom.
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.
  #6 (permalink)  
Old January 15th, 2009, 12:30 PM
Lee Dumond's Avatar
Wrox Author
Points: 4,942, Level: 29
Points: 4,942, Level: 29 Points: 4,942, Level: 29 Points: 4,942, Level: 29
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2008
Location: Decatur, IL, USA.
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(); 
}
  #7 (permalink)  
Old January 15th, 2009, 01:31 PM
Friend of Wrox
 
Join Date: Dec 2008
Location: , , .
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.
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 08: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 12:08 PM
document node order vs sort node order. ladyslipper98201 XSLT 2 June 5th, 2003 11:06 AM



All times are GMT -4. The time now is 02:11 AM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.