Click here to Skip to main content
15,881,413 members
Home / Discussions / C#
   

C#

 
AnswerRe: C# visual studio 2010 Pin
Member 94105226-Sep-12 4:17
Member 94105226-Sep-12 4:17 
GeneralRe: C# visual studio 2010 Pin
Pete O'Hanlon6-Sep-12 4:48
mvePete O'Hanlon6-Sep-12 4:48 
QuestionC# using linq Pin
classy_dog6-Sep-12 3:45
classy_dog6-Sep-12 3:45 
AnswerRe: C# using linq Pin
Pete O'Hanlon6-Sep-12 4:02
mvePete O'Hanlon6-Sep-12 4:02 
AnswerRe: C# using linq Pin
Clifford Nelson6-Sep-12 13:48
Clifford Nelson6-Sep-12 13:48 
Questionsize of fileupload Pin
ptvce5-Sep-12 21:13
ptvce5-Sep-12 21:13 
AnswerRe: size of fileupload Pin
Shameel5-Sep-12 22:56
professionalShameel5-Sep-12 22:56 
AnswerRe: size of fileupload Pin
Pete O'Hanlon5-Sep-12 23:37
mvePete O'Hanlon5-Sep-12 23:37 
That code doesn't work because ASP.NET is a server side technology. In other words, you have to transfer the posted file to the server before it can work out how big it is. There are things that you can do, but they generally involve compromises - one trick is to use a flash uploader control which can get access to the users hard disk to retrieve this information. Alternatively, if you know that your clients aren't going to be using Internet Explorer, you can use this function:
JavaScript
<script type='text/javascript'> 
function showFileSize() {     
  var input, file;      
  if (typeof window.FileReader !== 'function') { 
    alert('The file API isn't supported by your browser'); 

    return;     
  }      
  input = document.getElementById('fileinput'); // Or whatever name your input control is...
  if (!input) {
    alert('You don't seem to have a file input control');
    return;
  }
  if (!input.files) {  
    alert('This browser doesn't seem to support files.'); 
    return;
  }
  if (!input.files[0]) { 
    alert('You havent picked a file');  
    return;
  }     

  file = input.files[0];
  alert("The file is " + file.size + " bytes");
</script>
If your clients have IE, you may have to use an ActiveX control.

A final note - you really should have posted this in the ASP.NET forum.

*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

"Mind bleach! Send me mind bleach!" - Nagy Vilmos


CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

QuestionC# WinService starts in win7 but not in win2088 Pin
Daniel Jansson5-Sep-12 20:56
Daniel Jansson5-Sep-12 20:56 
AnswerRe: C# WinService starts in win7 but not in win2088 Pin
Bernhard Hiller5-Sep-12 21:35
Bernhard Hiller5-Sep-12 21:35 
GeneralRe: C# WinService starts in win7 but not in win2088 Pin
Daniel Jansson5-Sep-12 21:38
Daniel Jansson5-Sep-12 21:38 
GeneralRe: C# WinService starts in win7 but not in win2088 Pin
Bernhard Hiller5-Sep-12 21:49
Bernhard Hiller5-Sep-12 21:49 
AnswerRe: C# WinService starts in win7 but not in win2088 Pin
Shameel5-Sep-12 22:58
professionalShameel5-Sep-12 22:58 
AnswerRe: C# WinService starts in win7 but not in win2088 Pin
jschell6-Sep-12 12:48
jschell6-Sep-12 12:48 
QuestionC# Class for Finger Print Capture Pin
Member 23279205-Sep-12 20:25
Member 23279205-Sep-12 20:25 
AnswerRe: C# Class for Finger Print Capture Pin
Shameel5-Sep-12 20:38
professionalShameel5-Sep-12 20:38 
AnswerRe: C# Class for Finger Print Capture Pin
Thomas Duwe5-Sep-12 22:18
Thomas Duwe5-Sep-12 22:18 
QuestionPicture box click event Pin
Soni_moni5-Sep-12 19:43
Soni_moni5-Sep-12 19:43 
AnswerRe: Picture box click event Pin
Shameel5-Sep-12 20:36
professionalShameel5-Sep-12 20:36 
AnswerRe: Picture box click event Pin
DaveyM696-Sep-12 3:18
professionalDaveyM696-Sep-12 3:18 
QuestionC# MIDI controller interface. Pin
Jumpin' Jeff5-Sep-12 16:38
Jumpin' Jeff5-Sep-12 16:38 
AnswerRe: C# MIDI controller interface. Pin
DaveyM695-Sep-12 22:17
professionalDaveyM695-Sep-12 22:17 
GeneralRe: C# MIDI controller interface. Pin
Jumpin' Jeff6-Sep-12 14:26
Jumpin' Jeff6-Sep-12 14:26 
GeneralRe: C# MIDI controller interface. Pin
DaveyM697-Sep-12 0:57
professionalDaveyM697-Sep-12 0:57 
GeneralRe: C# MIDI controller interface. Pin
Jumpin' Jeff7-Sep-12 1:36
Jumpin' Jeff7-Sep-12 1:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.