Check contain value in TextBox in ASP.Net

Check contain value in TextBox in ASP.Net using Contains()

- We will learn here in TextBox control Found the Value in TextBox Control OR Not with help of Contains() Funcation.

- The Contains() Function use to check the Value or Found the Value in TextBox Control OR Not.

 

- write below code in head tag :-

<body>
    <form id=”form1″ runat=”server”>
<table>
                        <tr>
                            <td style=”width: 100px; text-align: right”>
                                Enter Value :</td>
                            <td style=”width: 100px”>
                                <asp:TextBox ID=”txtvalue” runat=”server”></asp:TextBox></td>
                            <td style=”width: 100px”>
                            </td>
                        </tr>
                        <tr>
                            <td style=”width: 100px”>
                            </td>
                            <td colspan=”2″ style=”text-align: left”>
                                <asp:Button ID=”btnsubmit” runat=”server” OnClick=”btnsubmit_Click” Text=”Submit” />
                                </td>
                        </tr>
                        <tr>
                            <td style=”width: 100px; text-align: right”>
                                </td>
                            <td colspan=”2″ style=”text-align: left”>
                                <asp:Label ID=”Label1″ runat=”server” Font-Bold=”True”></asp:Label></td>
                        </tr>
                    </table> </form>
</body>

 

Write below code in Button Click Event:-

protected void btnsubmit_Click(object sender, EventArgs e)
    {
 if (txtvalue.Text.Contains(“meera”))
        {
            Label1.Text = “Value contain ‘meera’ !”;
        }
        else
        {
            Label1.Text = “Value Dosn’t contain ‘meera’ !”;
        }
}

TextBox Control Contains() in ASP.Net

TextBox Control Contains() in ASP.Net

 

TextBox control Contains() in ASP.Net

TextBox control Contains() in ASP.Net

- I hope you enjoy this ASP.Net TextBox Example Tutorials.

Leave a Reply

Your email address will not be published. Required fields are marked *

3 + 5 =


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">