Author: Happy_Learner | Posted on: 7/6/2009 1:14:32 PM | Views : 246

All,
I have a grid; in that grid's edit form template i have placed one file upload control to upload image files.
To validate the file path and the file types i am using the following piece of code
<asp:FileUpload ID="ThumbNailUpload" runat="server" onkeydown="javascript: return cancelEnterKey (this, event)" onchange="" /> <asp:RegularExpressionValidator ID="FilePathRegExValidator" runat="server" ValidationExpression='^((?:[a-zA-Z]:)|(?:\\{2}\w[-\w]*)\$?)\\(?!\.)((?:(?![\\/:*?<>"|])(?![.\x20](?:\\|$))[\x20-\x7E])+\\(?!\.))*((?:(?:(?![\\/:*?<>"|])(?![..]$)[\x20-\x7E])+)\.((?:(?![\\/:*?<>"|])(?![ .]$)[\x20-\x7E])+))
ControlToValidate="ThumbNailUpload" ErrorMessage="Invalid File path." Text ...

Go to the complete details ...