检查文本框中的某些文本asp.net c#

时间:2012-08-30 17:12:04

标签: c# asp.net validation textbox

如何检查文本框是否包含“@ mediacollege.dk”,如下所示

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
}

1 个答案:

答案 0 :(得分:1)

你可以这样做

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