<asp:FileUpload ID="fuFile" runat="server" />
<asp:CustomValidator ID="CustomValidator1" runat="server" ControlToValidate="fuFile"
ErrorMessage="File size should not be greater than 1 KB." OnServerValidate="CustomValidator1_ServerValidate"></asp:CustomValidator>
protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
{
if (fuFile.FileBytes.Length > 1024) // 1024*KB of file size
{
args.IsValid = false;
}
else
{
args.IsValid = true;
}
}