Reputation: 316
I have the following element in .NET6 Application's razor view:
<input type="number" placeholder=@((Model.Child?.Name ?? "DefaultName") + " SomeExtraText")>
Expected output when the Name attribute is not null is: "Name SomeExtraText". However I only get "Name" as the output.
When I change " SomeExtraText" to "-SomeExtraText" I get the output as "Name-SomeExtraText".
I also tried using String.Format as follows:
<input type="number" placeholder=@(String.Format("{0}{1}",(Model.Child?.Name ?? "DefaultName"), " SomeExtraText"))>
but the result is same.
What is the reason for that?
Upvotes: 2
Views: 61
Reputation: 8950
Add additional quotes:
<input type="number" placeholder="@((Model.Child?.Name ?? "DefaultName") + " SomeExtraText")">
Upvotes: 3