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 in the project view to define the event handler in the code 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 will need to define a mysterious method that you just called "StrToByt" in the same file to define this method, which will take the string str as a parameter and set its encoding through the object "System.Text.UTF8Encoding" and then return output in the form of a string, which we will consider using the Length property
public static byte[] StrToByt(string str)
{
System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
return encoding.GetBytes(str);
}
PS: , - UTF-8, , "System.Text.UTF8Encoding", "System.Text." " "
, , , ! =)