943,809 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Marked Solved
  • Views: 753
  • ASP.NET RSS
Feb 23rd, 2009
0

prevent upload control from uploading a blank file

Expand Post »
hi, i have set a condition on the upload function

ASP.NET Syntax (Toggle Plain Text)
  1. if (FileUploadControl1.PostedFile == null) {
  2.  
  3. lblResult.Text = "Please select a file first";
  4.  
  5. }
  6.  
  7. else
  8.  
  9. {
  10. //upload a file
  11. }

but if i press upload button when no file is selected it still uploads a blank file regardless of the "if' condition i set, does any1 know why this might be?

cheers
Last edited by peter_budo; Feb 24th, 2009 at 7:28 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reputation Points: 10
Solved Threads: 0
Light Poster
julseypart is offline Offline
42 posts
since Oct 2008
Feb 24th, 2009
0

Re: prevent upload control from uploading a blank file

Try this:
if (FileUploadControl1.HasFile)
{
    //upload a file   
}
else
{
    lblResult.Text = "Please select a file first";   
}
Reputation Points: 16
Solved Threads: 18
Junior Poster
Aneesh_Argent is offline Offline
104 posts
since Dec 2008
Feb 25th, 2009
0

Re: prevent upload control from uploading a blank file

thanks that worked!
Reputation Points: 10
Solved Threads: 0
Light Poster
julseypart is offline Offline
42 posts
since Oct 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: Get treeview selected node using javascript
Next Thread in ASP.NET Forum Timeline: Sys.Webforms.PageRequestManagerServerErrorEexception from deploy machine





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC