0

I have one string which is class course type as "database subject".I want to display it as "Database Subject" means capitalize the string. And given string is dynamic.

foreach (var registration in Model.Registrations)
{
   <br /><text> - -@registration.Class.Type.Course</text>
   // Database Subject  
}

I want to implement above changes in razor view.

Camilo Terevinto
  • 31,141
  • 6
  • 88
  • 120
sbm6070
  • 45
  • 2
  • 7
  • Please paste the class of `Type`. Usually I do this in the controller, in case I need to expose the same data to an API, the display would be the same. If you *know* for fact that you aren't going to expose this data let me know. There are some great ways to do this without having to add tons of code to your Razor pages (like using `ToTitleCase` on every page, don't do that). – Erik Philips Nov 06 '17 at 19:10
  • maybe this will help https://stackoverflow.com/questions/12712875/how-to-capitalize-first-letter-razor – fdistorted Nov 06 '17 at 19:15
  • 1
    this answer to be specific : https://stackoverflow.com/a/32180052/1875256 – Ehsan Sajjad Nov 06 '17 at 19:16
  • I cant use CSS or not make string as Capitalize in .cs file – sbm6070 Nov 06 '17 at 19:24
  • I have use following code to display string in capital letters in razor view. @System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(registration.Class.Type.Course) – sbm6070 Nov 07 '17 at 14:02

0 Answers0