Hi nauna,
Refer Below code.
HTML
Value:<asp:TextBox runat="server" ID="txtValue" />
<br /><br />
<asp:Button Text="Submit" runat="server" OnClick="Submit"/>
Code
C#
protected void Submit(object sender, EventArgs e)
{
if (txtValue.Text.Trim().EndsWith("M"))
{
ClientScript.RegisterClientScriptBlock(this.GetType(), "", "alert('" + Math.Round((Convert.ToDecimal(txtValue.Text.TrimEnd('M')) * 1000000), 0) + "')", true);
}
else if (txtValue.Text.Trim().EndsWith("K"))
{
ClientScript.RegisterClientScriptBlock(this.GetType(), "", "alert('" + Math.Round((Convert.ToDecimal(txtValue.Text.TrimEnd('K')) * 1000), 0) + "')", true);
}
}
VB.Net
Protected Sub Submit(ByVal sender As Object, ByVal e As EventArgs)
If txtValue.Text.Trim().EndsWith("M") Then
ClientScript.RegisterClientScriptBlock(Me.GetType(), "", "alert('" & Math.Round((Convert.ToDecimal(txtValue.Text.TrimEnd("M"c)) * 1000000), 0) & "')", True)
ElseIf txtValue.Text.Trim().EndsWith("K") Then
ClientScript.RegisterClientScriptBlock(Me.GetType(), "", "alert('" & Math.Round((Convert.ToDecimal(txtValue.Text.TrimEnd("K"c)) * 1000), 0) & "')", True)
End If
End Sub
Screenshot