Detect asp:FileUpload has a file using Jquery?

I am using file upload

<asp:FileUpload ID="ImageUploader" runat="server"/>

how can i detect that asp:FileUpload has a file using Jquery?

I am doing this

$("#ctl00_MainContentPlaceHolder_UCUpdOrgProfile1_ImageUploader").change(function (e) {

But i dont know either file is selected or not.


check -

if (document.getElementById('<%= ImageUploader.ClientID %>').files.length === 0) 
   // File upload do not have file
else {
   // File upload has file

Valid answers, or since ASP 4+ just set ClientIDMode as a page property:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default" ClientIDMode="Static" %>

The ClientID value is set to the value of the ID property. If the control is a naming container, the control is used as the top of the hierarchy of naming containers for any controls that it contains. - reference

ie. this will force ASP to obey the ID as declared and not generate the "ctl00_" prefix or any other. This is awesome as it is applied to the whole page and all asp controls contained on it, no extra code, no hacks just one awesome property.

So apply the same logic as @Microsoft_DN solution, but use static ID's.

Need Your Help

How do I themeroll jGrowl

jquery-ui themeroller jgrowl

I am working on building a site and i'm trying to use jquery ui themes for as much of the styling as possible. and the jGrowl site says it can be theme rolled.

preg_match: check birthday format or

php date get preg-match

I want to get the date from string in format: or

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.