How to Pre validate Image size in fileupload
<p>I have a fileupload control. I want, when a user browse a image through this control of size more than 50 kb , an error message should display. How to do this?
I have one customvalidator as below...</p>

<pre><code>&lt;asp:FileUpload ID="Fileupload1" runat="server"/&gt;

&lt;asp:CustomValidator ID="CustomValidator1"
                     runat="server"
                     ErrorMessage="not valid size"
                     Display="Dynamic"
                     ValidationGroup="I"
                     ControlToValidate="Fileupload1"
                     OnServerValidate="CustomValidator1_ServerValidate"
                     CssClass="validationCss"&gt;
&lt;/asp:CustomValidator&gt;

protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
    {
        if (Fileupload1.HasFile)
        {
            if (Fileupload1.PostedFile.ContentLength &amp;amp;gt;= 20960)
            {
                args.IsValid = false;
               // this.ModalPopupExtender1.Show();
            }
            else
            {
                args.IsValid = true;
            }
        }
    }
</code></pre>

<p>My validation is working, but when i click on the done button.
I want error message before I click the button.</p>

<pre><code> &lt;script type="text/javascript"&gt;
function OnBrowse()
{
if(Page_ClientValidate("I"))
{
///Your login here......
alert("something....");
return false;
}
return true;
}
&lt;/script&gt;
</code></pre>
