user1497360
user1497360

Reputation: 37

Check a textbox for some certain text asp.net c#

How do I check if a textbox contains "@mediacollege.dk" in like this

if (email.text == "here it checks if it contains "@mediacollege.dk" and does a command")
{
    DHF_LodderTableAdapter DHFLodder = new DHF_LodderTableAdapter();
    DHFLodder.Insert(UserName.Text, 10);
}
else
{
    // nothing
}

Upvotes: 0

Views: 2505

Answers (1)

Waqar Janjua
Waqar Janjua

Reputation: 6123

You can do it as

if (email.text.Contains("@mediacollege.dk") )
 {
        // do your work
     DHF_LodderTableAdapter DHFLodder = new DHF_LodderTableAdapter();
     DHFLodder.Insert(UserName.Text, 10);    
}
else
{
    // nothing
}

Upvotes: 1

Related Questions