Solved

Excel file checking using RegularExpressionValidator

Posted on 2007-03-19
3
460 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

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…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

728 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

11 Experts available now in Live!

Get 1:1 Help Now