count_number.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="count_number.aspx.cs" Inherits="our_program.count_number" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Count number of integers </title>
<center><h1>Count number of integers</h1></center>
</head>
<body>
<form id="form1" runat="server">
<center>
<div>
<asp:TextBox ID="txt" runat="server" ></asp:TextBox>
<br />
<br />
<asp:Label ID="lbl" runat="server" Text="count of digit is shown here"></asp:Label>
<br />
<br />
<asp:Button ID="btn" runat="server" Text="submit" onclick="btn_Click" />
</div>
</center>
</form>
</body>
</html>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="count_number.aspx.cs" Inherits="our_program.count_number" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Count number of integers </title>
<center><h1>Count number of integers</h1></center>
</head>
<body>
<form id="form1" runat="server">
<center>
<div>
<asp:TextBox ID="txt" runat="server" ></asp:TextBox>
<br />
<br />
<asp:Label ID="lbl" runat="server" Text="count of digit is shown here"></asp:Label>
<br />
<br />
<asp:Button ID="btn" runat="server" Text="submit" onclick="btn_Click" />
</div>
</center>
</form>
</body>
</html>
count_number.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace our_program
{
public partial class count_number : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btn_Click(object sender, EventArgs e)
{
string a = txt.Text;
char[] array = a.ToCharArray();
int count = 0;
int ncount = 0;
string output = "";
for (int i = 0; i < array.Length; i++)
{
string b = array[i].ToString();
if(int.TryParse(b,out ncount)==true)
{
output = output + "," + ncount.ToString();
count++;
}
}
lbl.Text = "no of integer " + count + " numbers " + output;
}
}
}
No comments:
Post a Comment