⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 defaultcs.aspx.cs

📁 Telerik是很大的第三方软件制造商
💻 CS
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using Telerik.QuickStart;
using Telerik.WebControls;
using Telerik.WebControls.CallbackControls;

namespace Telerik.CallbackExamplesCSharp.Controls.TextBox
{
	/// <summary>
	/// Summary description for _Default.
	/// </summary>
	public class DefaultCS: XhtmlPage
	{
		protected System.Web.UI.WebControls.Label Label1;
		protected System.Web.UI.WebControls.Label Label2;
		protected System.Web.UI.WebControls.Label Label3;
		protected System.Web.UI.WebControls.Label Label4;
		protected System.Web.UI.WebControls.Label Label5;
		protected System.Web.UI.WebControls.Label Label9;
		protected System.Web.UI.WebControls.Label Label11;
		protected System.Web.UI.WebControls.Label lblLetters;
		protected System.Web.UI.WebControls.Label lblConsonants;
		protected System.Web.UI.WebControls.Label lblVowels;
		protected System.Web.UI.WebControls.Label lblCapitals;
		protected System.Web.UI.WebControls.Label Label6;
		protected System.Web.UI.WebControls.Label lblWhiteSpace;
		protected System.Web.UI.WebControls.Label Label7;
		protected System.Web.UI.WebControls.Label lblPunctuators;
		protected System.Web.UI.WebControls.Label Label8;
		protected System.Web.UI.WebControls.Label statusLabel;
		protected System.Web.UI.HtmlControls.HtmlImage Img1;
		protected Telerik.WebControls.LoadingPanel LoadingPanel1;
		protected Telerik.WebControls.CallbackTextBox CallbackTextBox1;

		private void Page_Load(object sender, System.EventArgs e)
		{
			// Put user code to initialize the page here
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		///		Required method for Designer support - do not modify
		///		the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.CallbackTextBox1.KeyUp += new Telerik.WebControls.CallbackControls.KeyPressEventHandler(this.CallbackTextBox1_KeyUp);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion


		private int GetConsonants(string s)
		{
			int count = 0;
			foreach (char ch in s)
			{
				if (char.IsLetter(ch))
				{
					switch (ch)
					{
						case 'a':
						case 'e':
						case 'i':
						case 'o':
						case 'u':
						case 'y':
						{							
							break;
						}
						default:
						{
							count++;
							break;
						}
					}
					
				}
			}
			return count;
		}

		private int GetVowels(string s)
		{
			
			int count = 0;
			
			foreach (char ch in s)
			{
				switch (ch)
				{
					case 'a':
					case 'e':
					case 'i':
					case 'o':
					case 'u':
					case 'y':
					{
						count++;
						break;
					}
				}
			}
			return count;			
		}

		private int GetWhiteSpaces(string s)
		{
			int count = 0;
			foreach (char ch in s)
			{
				if (char.IsWhiteSpace(ch))
				{
					count++;
				}
			}
			return count;
		}

		private int GetCapitals(string s)
		{
			int count = 0;
			foreach (char ch in s)
			{
				if (char.IsUpper(ch))
				{
					count++;
				}
			}
			return count;
		}

		private int GetPunctuators(string s)
		{
			int count = 0;
			foreach (char ch in s)
			{
				if (char.IsPunctuation(ch))
				{
					count++;
				}
			}
			return count;
		}

		private void CallbackTextBox1_KeyUp(object sender, KeyEventArgs args)
		{
			Label1.Text = CallbackTextBox1.Text;			

			lblLetters.Text = Label1.Text.Length.ToString();
			lblConsonants.Text = GetConsonants(Label1.Text).ToString();
			lblVowels.Text = GetVowels(Label1.Text).ToString();
			lblCapitals.Text = GetCapitals(Label1.Text).ToString();
			lblWhiteSpace.Text = GetWhiteSpaces(Label1.Text).ToString();
			lblPunctuators.Text = GetPunctuators(Label1.Text).ToString();
		}

	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -