Thursday, 12 April 2012

how to word count in asp.net


Here discuss how to word count some important Logic in c# ? we can use click event and write code easily. 


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


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

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        String stringtrim = TextBox1.Text;
        int strringLenth = stringtrim.Length;
        Label1.Text = (strringLenth.ToString());


    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        string stringtrim = TextBox1.Text;
        string[] strtrim = stringtrim.Split(' ');
        int i = strtrim.Length;
        Label1.Text = i.ToString();
    }
    protected void TextBox1_TextChanged(object sender, EventArgs e)
    {
    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        int sum = 0;
        string[] strtrim = TextBox1.Text.Split(' ');
        for (int i = 0; i <= strtrim.Length - 1; i++)
        {
            int j=strtrim[i].Length;
            sum += j;
        }
        String str = TextBox1.Text;
        str.Trim();
        int count = str.Length;
        Label1.Text = sum.ToString();
    }
    protected void Button4_Click(object sender, EventArgs e)
    {
       
    }
}


No comments:

Post a Comment

What is ASP.NET? Components of ASP.NET

ASP.Net Definition -It is used for creating web-based applications.ASP.Net is a web development platform provided by Microsoft. ASP.NET i...