Solved

Excel file checking using RegularExpressionValidator

Posted on 2007-03-19
3
467 Views
Last Modified: 2008-01-09
Hi

I am working on ASP.net2.0, C#

I have a regular expression which checks if file is xls or not

It works fine, if we sellect the file from local system or map drive

But it does not work if we take the file from map drive

like
\\barney\Testing\Excel Example_R1.xls

My RegularExpressionValidator is

<asp:RegularExpressionValidator id="RegExpFile" runat="server" ErrorMessage=" "
ControlToValidate="FileUpload1" ValidationExpression="^.+\.((xls)|(XLS)|(Xls))$"></asp:RegularExpressionValidator>


Please help

This is very urgent for me
0
Comment
Question by:dinesh_bali
3 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 18749605
It looks like the expression should work for
\\barney\Testing\Excel Example_R1.xls
Does it make any difference if you omit the "^.+"
0
 

Author Comment

by:dinesh_bali
ID: 18750278
Sorry, It was [a-zA-Z0_9].*\bxls\b

Is the ="^.+\.((xls)|(XLS)|(Xls))$

As I only want user should select only excel file, he should not able to select any other file

Thanks
0
 
LVL 16

Accepted Solution

by:
AlexNek earned 500 total points
ID: 18753063
It is look OK, it can parse the lines. I test exresion. It is possible that you have an additional symbol in "wrong line" or missied new line symbol.
^ (anchor to start of string)
. (any character)
+ (one or more times)
.
Capture
  Capture
    xls
  End Capture
    or
  Capture
    XLS
  End Capture
    or
  Capture
    Xls
  End Capture
End Capture
$ (anchor to end of string)
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Connection String 16 54
Counting connections to SQL Server through C# 3 32
Set value of dynamically created checkboxlist 2 31
C# winforms programmitically move panels 6 27
Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now