<asp:fileupload id="FileUpload1" runat="server" xmlns:asp="#unknown" />
Put a div behind
to hold the error message
<div id="spnErrorLogo" runat="server">
</div>
Now add the following code at code behind
Int64 intFileSize = Convert.ToInt64(FileUpload1.PostedFile.ContentLength);
if (intFileSize > 3145728)
{
spnErrorLogo.InnerHtml = "Maximum file size exceeded.
Please upload a file less than 3 MB in size.";
}