Check Textbox Value IsNumeric or String Using Asp.Net C#

Check Textbox Value IsNumeric or String 

If Enter Values in Textbox Check whether it is Numeric or String Values  Using Asp.Net C#. 


                                DEMO




                             Download
                        
                         HTML Coding



<html>
<head>
    <title></title>
   
</head>
<body>
    <form id="form1" runat="server">
        <div align="center">           

        <asp:Label ID="Label1" runat="server" Font-Size="Larger" Text="Input "></asp:Label>
            <asp:TextBox ID="txtInput" runat="server"></asp:TextBox>
        <br />
        <br />
        <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="IsNumeric" />
        </div>
    </form>
</body>

</html>


                             C# Coding


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        int Numeric;

        bool IsNumeric = int.TryParse(txtInput.Text, out Numeric);

        Response.Write("<script>alert('" + IsNumeric + "')</script>");

    }
   
}



Add New Web Form  -  Select Required Textbox & Lable & Button From Toolbox







Next -  Check Boolean Values If Numeric or String





0 comments:

Post a Comment