Hello,
After testing your code, there is no problem with the way the number is parsed. 7,344.55 can be converted to 7344.55 and displayed in the Blazor page. This should be a problem when you set the Blazor page code variable.
You can refer to the following runnable code.
<p role="status">@close</p>
<button class="btn btn-primary" @onclick="@Replace">Click me</button>
@code {
private string str = "7,344.55";
private float close;
private void Replace()
{
bool isCloseParsed = false;
if (this.str.Contains(","))
{
string newclsd = this.str.Replace(",", "");
isCloseParsed = float.TryParse(newclsd, out this.close);
}
else
{
isCloseParsed = float.TryParse(this.str, out this.close);
}
}
}
Best Regards,
Alec Liu.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.