Solved

Excel file checking using RegularExpressionValidator

Posted on 2007-03-19
3
468 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

839 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