Asp.Net Login Website creation
-
Monday, April 09, 2012 9:50 PM
hi all,
This is velsamy , i have created a login Website using ASP.NET(C#) , what is the problem means, I have to prevent the special characters in the username textbox also i have tried a way like :
Code Behind:
protected void ValidateNoUrls(object sender, ServerValidateEventArgs e)
{
e.IsValid = !Regex.IsMatch(e.Value, @"(ht|f)tp(s?)\:\/\/[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*(:(0-9)*)*(\/?)([a-zA-Z0-9\-\.\?\,\'\/\\\+&%\$#_]*)?");
}aspx:
<asp:TextBox ID="TextBox1" runat="server" MaxLength="15" Width="220px" />
<asp:CustomValidator runat="server" OnServerValidate="ValidateNoUrls" ControlToValidate="TextBox1" ErrorMessage="Urls not allowed"/>While i Triying this code there is a Compiler Error Message: CS0103: The name 'Regex' does not exist in the current context.
So anyone can help me,
Thanks in advance,
Velsamy A
- Moved by CoolDadTxMVP, Moderator Tuesday, April 10, 2012 5:05 PM Not IDE related (From:Visual C# IDE)
All Replies
-
Tuesday, April 10, 2012 4:07 AM
Velsamy A,
Have you added reference to below namespace in the code behind?
Namespace: System.Text.RegularExpressions
Assembly: System (in System.dll)-Tejas.
- Proposed As Answer by Narendran Ponpandiyan Thursday, April 12, 2012 6:52 AM
- Marked As Answer by Bob ShenMicrosoft Contingent Staff, Moderator Monday, April 23, 2012 4:07 AM
-
Thursday, April 12, 2012 3:07 AMModerator
Hi Velsamy,
You can consider posting it at the following more appropriate forum for more efficient responses. Thanks!
ASP.Net Forum http://forums.asp.net/
Bob Shen [MSFT]
MSDN Community Support | Feedback to us

