How to get the ASCII value in C#

Abstract


Just Drag and drop the Text box and button control to your web page.In run time
give the input to Text box then click the button control the result will be display in your page.


[code]
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

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 i = 0;
string strInput ="";
string strTemp ="";
strInput = TextBox1.Text.ToString().Trim();
for (i = 0; i <= strInput.Length - 1; i++)
{
int charValue = Convert.ToInt32(strInput[i]); // converting in ascii
if (strTemp == "")
{
Response.Write(charValue);
Response.Write("
");
}
else
{
Response.Write(charValue);
Response.Write("
");
}
}
}
}

[/code]

No comments:

Post a Comment

Plz Share your comments...