You can set the limit in web configuration, the property is called MaxRequestLength.
Install it in web.config in the httpRuntime section:
<httpRuntime executionTimeout="90" maxRequestLength="4096" /> <-- number of bytes
This should be inserted under <system.web>
As for checking file size, it's as simple as
If txtFileUpload.PostedFile.ContentLength > 1024 Then <-- bytes
Marko source share