I think your answer is here
Calculate.aspx :
<body>
<form id="form1" runat="server">
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
</form>
</body>
Then double click the button on the design view to define the event handler in the code-behind file (Calculate.aspx.cs) then add the following code to the method
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = StrToByt(TextBox1.Text).Length.ToString();
}
Finally you'll have to define the mysterious method that you just called "StrToByt" in the same file define this method that will take a string str as a parameter and set it's encoding through the "System.Text.UTF8Encoding" object and then return the output as a string which we will count through Lenth property
public static byte[] StrToByt(string str)
{
System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
return encoding.GetBytes(str);
}
P.S : I researched a little bit and found that the common encoding is UTF-8, but if you think otherwise you can just edit the encoding object instead of "System.Text.UTF8Encoding" you can type "System.Text." and you'll find in the Text name space all the encoding types available
If you was a little confused I could post the full code, HOPE IT HELPS! =)