Find word with in string in ASP.Net using C# and VB.Net

t01714500930
 
on Mar 22, 2021 05:40 AM
1099 Views

if "aspforums" word in label3 then label4 text good site.

label3.Text = "site is aspforums good site"
if(label3.text == like "aspforums" word)
{

}
else
{

}

 

Download FREE API for Word, Excel and PDF in ASP.Net: Download
dharmendr
 
on Mar 22, 2021 05:45 AM
on Jan 04, 2022 09:33 AM

Hi t01714500930,

Refer below code.

HTML

<asp:Label ID="Label3" runat="server"  Text="Welcome to aspforums." /><br />
<asp:Label ID="Label4" runat="server" />

Code

C#

protected void Page_Load(object sender, EventArgs e)
{
    if(label3.Text.Contains("aspforums"))
    {
        label4.text = "good site";
    }
    else
    {
        label4.text = "";
    }
}

VB.Net

Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
    If label3.Text.Contains("aspforums") Then
        label4.text = "good site"
    Else
        label4.text = ""
    End If
End Sub

Output

aspforums