Try this example :
<asp:CustomValidator ID="valFileSize" runat="server" ErrorMessage="The image exceeds 10 MB" onservervalidate="valFileSize_ServerValidate" Display="Dynamic" />
The method that actually performs the validation looks like this one:
protected void valFileSize_ServerValidate(object source, ServerValidateEventArgs args)
{
if (IsValid)
{
int maxSize = 5 * 1024 * 1024;
if (fileImage.PostedFile.ContentLength > maxSize)
{
args.IsValid = false;
}
}
}
and in web.config
<httpRuntime maxRequestLength="20480"/>
Good Luck
Monday, December 15, 2008
Validate Image Size
Subscribe to:
Post Comments (Atom)


No comments:
Post a Comment