Decimal format of RadzenNumeric is always localized despite culture set to invariant in WASM

I want to force a RadzenNumeric with a value type of double to display the value in the invariant culture. I have this:

    <RadzenNumeric TValue="double"
                   ... more ... />

In my Program.cs on the Server side, I have:

var app = builder.Build();
app.UseRequestLocalization(new RequestLocalizationOptions {
    DefaultRequestCulture = new RequestCulture("en-US"),
    SupportedCultures = new[] { CultureInfo.InvariantCulture },
    SupportedUICultures = new[] { CultureInfo.InvariantCulture }

I am using Blazor with .net 8 in Auto render mode. When the component is rendered on the server, entering e.g. "3.5" displays 3.5 correctly. However, when the component is rendered via WASM, it is always displayed as 3,5 (i.e., German).
This does not happen when starting the application from Visual Studio.

Am I missing any additional settings for the Client side project?

You have option to specify Numeric Culture on component level:

You can also try displaying a number using to string to see how it would render.


@code {
    double value = 3.5;

There was a setting whether to embed culture info in web assembly. You may also have to set

1 Like

In Blazor Server i use the following code in Program.cs, so i dont have to define on each component the Culture.
I dont know if this can help, give it a try.

using System.Globalization;
var builder = WebApplication.CreateBuilder(args);
CultureInfo.DefaultThreadCurrentCulture = Definitions.myCulture;
CultureInfo.DefaultThreadCurrentUICulture = Definitions.myCulture;
CultureInfo.CurrentCulture = Definitions.myCulture;
CultureInfo.CurrentUICulture = Definitions.myCulture;
Thread.CurrentThread.CurrentCulture = Definitions.myCulture;
Thread.CurrentThread.CurrentUICulture = Definitions.myCulture;

Replace "Definitions.myCulture" with urs

1 Like

I put both the code snippet from @korchev into my server .csproj and the snippet from @GodzSky into my Program.cs both on client and server and this now causes the RadzenNumerics to use the invariant culture. Thanks.

1 Like