About the author

Vijay Kodali
E-mail me Send mail

Site Statistics

Site Meter

Recent comments

Authors

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2014

Microsoft releases CTP of Visual studio 2010 and Dot net framework 4.0

According to Scott Guthrie VS2010 was built using the Windows Presentation Foundation. VS2010 will offer features like multi-monitor support, richer code editing and richer code visualization.

Check this .Net 4.0 framework poster


Tags:
Categories: General
Posted by vijay on Thursday, October 30, 2008 7:36 PM
Permalink | Comments (0) | Post RSSRSS comment feed

Validate Asp.Net FileUpload control

Here is an example to validate Fileupload control. This validation will check user to upload files of particular type/extension.

Client side validation:

 

<asp:FileUpload ID="UploadFile" runat="server" />
<asp:Button Text="Save" ID="btnSave" runat="server" OnClientClick="javascript:return ValidateUpload();" />     
 <script type="text/javascript" language="javascript">
    function ValidateUpload()
            {           
                var Upload_file = document.getElementById('<%= UploadFile.ClientID %>');                
                var myfile = Upload_file.value;               
                if(myfile.indexOf("doc")>0)
                {
                 alert('Valid Format');
                }
                else
                {
                 alert('Invalid Format');
                }            
            }
 </script>
Validating with RegularExpression validator:
<asp:FileUpload ID="UploadFile" runat="server" />
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="Only Doc files are allowed" 
ControlToValidate="UploadFile" ValidationExpression="^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))+(.doc|.DOC)$">
</asp:RegularExpressionValidator>

In this example, I checked  ".doc" file type but you can use this example for any file type. Just replace ".doc" with file type you would  like to check( "Xml", "wmv"...).


Categories: ASP.NET | ASP.Net 3.5
Posted by vijay on Thursday, October 16, 2008 8:26 PM
Permalink | Comments (3) | Post RSSRSS comment feed