ApplicationDBContext.cs
Below code is written in .net core :Description value should display with bold & unbold text in application UI
modelBuilder.Entity
{
Id = 1,
Description = "C# Corner should display in Bold ,C# Corner should display unbold"
});
Tuhin PaulPosted May 13, 2023, 3:28 AM
In your Razor view, use the following code to render the Description value:
In your controller action, use the following code to get the Description value and split it into two parts:
In your controller action, use the following code to set the boldText and unboldText properties:
By following these steps, you can make the Description value display with bold & unbold text in application UI.
Mohamed Azarudeen ZPosted May 12, 2023, 8:52 AM
To format text in the
DbContextclass, you can use HTML tags like in your example, whereandtags are used to make the text bold. However, you need to keep in mind that the formatting tags will not be automatically applied in the application UI.You need to use a text control that can interpret HTML, such as a
WebViewcontrol in WPF or WinForms, or anHtmlHelperin ASP.NET MVC. Then, you can pass the formatted text to the control, and it will render the text with the appropriate formatting.For example, in ASP.NET MVC, you can use the
HtmlHelper.Rawmethod to output the HTML tags in the view:@model BoldValues
@Html.Raw(Model.Description)