Just use a custom validator with the following javascript function:
function UploadFileCheck(source, arguments)
{
var sFile = arguments.Value;
arguments.IsValid =
((sFile.endsWith('.jpg')) ||
(sFile.endsWith('.jpeg')) ||
(sFile.endsWith('.gif')) ||
(sFile.endsWith('.png')));
}
The custom validator code:
<asp:CustomValidator ID="cvalAttachment" runat="server" ControlToValidate="upAttachment" SetFocusOnError="true" Text="*" ErrorMessage="Invalid: File Type (allowed types: jpg, jpeg, gif, png)" ClientValidationFunction="UploadFileCheck"></asp:CustomValidator>
That should be all your need to stop it client side before it gets posted back.