0

I was wondering if anyone could give me the code for email validation on a textbox named, txtEmail.

I have used a validator but there is a problem with IIS7 and this so i need to code it behind the text box. I would like to inform the user that they have not entered a valid email address via a message box and not allow them to proceed until it is correct..

Can anyone help me with this??

thanks

Eric

4
Contributors
6
Replies
9
Views
7 Years
Discussion Span
Last Post by sknake
Featured Replies
  • 1
    sknake 1,622   7 Years Ago

    You want to perform the validation server side in c# code behind right? Here is how I do it: [code=c#] public static bool IsValidEmailAddr(string email) { try { System.Net.Mail.MailAddress addr = new System.Net.Mail.MailAddress(email); } catch { return false; } return true; } [/code] Read More

0

Welcome erictheking1.

You should post your question in ASP.NET forum. Regarding to your problem you must have use javascript with RegExp (regular expression) pattern or RegularExpression Validator control.

0

Im sorry, maybe i didnt make myself clear. This is a c# question. The regular expression validators and every other validators throw an web reference error when i host the page. I have all ready researched this problem and microsoft are currently trying to find a solution. It has to do with IIS 7. (asp.net problem)

The question im asking is can anyone give me c# code that i can put behind a button so that the textbox must be in email address format before the user can proceed. An if statement or something equivalant.

Thanks

Eric

1

You want to perform the validation server side in c# code behind right? Here is how I do it:

public static bool IsValidEmailAddr(string email)
    {
      try
      {
        System.Net.Mail.MailAddress addr = new System.Net.Mail.MailAddress(email);
      }
      catch
      {
        return false;
      }
      return true;
    }
Comments
Deep respect...
This article has been dead for over six months. Start a new discussion instead.
Be sure to adhere to our posting rules.