Answered 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

All Replies