?
Solved

Help with Validation

Posted on 2008-11-10
3
Medium Priority
?
198 Views
Last Modified: 2012-05-05
Hi

I have the following line

if (rblEvaluation.SelectedValue == "Evaluation" && (!EvalURL.Contains("http://") && !EvalURL.Contains("https://")))

I've been told this is wrong, it should validate the begining of the string i.e.

it should check to see if http://    or   https://    appears at the beining of the string, the problem with the above is it validates the string anywhere in the string.

Hope this makes sense?

Thanks
Mosuemat
0
Comment
Question by:mousemat
3 Comments
 
LVL 8

Accepted Solution

by:
OBonio earned 500 total points
ID: 22922677
I assume you want to handle this if EvlaURL starts with http:// OR https:// otherwise it will always evaluate to false.

if (rblEvaluation.SelectedValue == "Evaluation" && (!EvalURL.StartsWith("http://") || !EvalURL.StartsWith("http://")))

Open in new window

0
 

Author Comment

by:mousemat
ID: 22922716
Thanks OBonio, I thought I'd had to do something like indexOf, substring etc to get this to work.


Thanks again
0
 
LVL 16

Expert Comment

by:Gyanendra Singh
ID: 22922778
use EvalURL.StartWith
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Integration Management Part 2
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

840 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