Sal-
Here's a post that discusses your concern:
http://groups.google.com/group/micr...3049c8821ec/4546302931d090b2#4546302931d090b2
It appears that, since the Browse window is controled by the host OS, that
it's not something you can manipulate (as you could on a WinForms application).
For a workaround, I'd agree with Ben that the content type is probably the
easiest to check since it's a bit more reliable than checking file extensions.
You can do this by accessing the object's ContentType property.
Pseudo-code:
if (FileUpload1.PostedFile.ContentType != "image/jpeg")
{
// logic here
}
If you have a list of valid content types, you can build a list and iterate
through it. For example:
1. Create a generic list of your valid content types.
private static List<String> ValidContentTypes()
{
List<String> validContentTypes = new List<String>();
validContentTypes.Clear();
validContentTypes.Add("image/gif");
validContentTypes.Add("image/jpeg");
validContentTypes.Add("image/pjpeg");
validContentTypes.Add("image/png");
return validContentTypes;
}
2. And then for your .PostedFile.ContentType:
List<String> _contentTypes = ValidContentTypes();
if (_contentTypes.Exists(delegate(string t) { return FileUpload1.PostedFile.ContentType
== t; }))
{
// Logic here
}
HTH.
-dl