Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Blazor, styling dynamic data

Blazor, styling dynamic data

Scheduled Pinned Locked Moved ASP.NET
asp-netquestion
3 Posts 2 Posters 16 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    Wiep Corbier
    wrote on last edited by
    #1

    I have dynamic data showing on a blazor page

                    @foreach (var item in DisplayList.OrderBy(i => i.CompanyId))
                    {
                        
                            @item.Company
                            @item.FunctionName
                            @item.Identifier
                            @item.SkillsSet
                        
                    }
    

    In my code I do a if..contains..replace on the part item.SkillsSet. This is a string. What I'm trying to do is: when this string contains a value I want that value to be surrounded with the "mark" tag so that part is highlighted. Like: Jo | Lisa | Me | John But the result is not what I expect. It shows the names and the tag. It doesn't highlight the text It shows:

    Jo | Lisa | Me | John

    What to do?

    Richard DeemingR 1 Reply Last reply
    0
    • W Wiep Corbier

      I have dynamic data showing on a blazor page

                      @foreach (var item in DisplayList.OrderBy(i => i.CompanyId))
                      {
                          
                              @item.Company
                              @item.FunctionName
                              @item.Identifier
                              @item.SkillsSet
                          
                      }
      

      In my code I do a if..contains..replace on the part item.SkillsSet. This is a string. What I'm trying to do is: when this string contains a value I want that value to be surrounded with the "mark" tag so that part is highlighted. Like: Jo | Lisa | Me | John But the result is not what I expect. It shows the names and the tag. It doesn't highlight the text It shows:

      Jo | Lisa | Me | John

      What to do?

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      Try using the Html.Raw helper method to indicate that the string should not be HTML-encoded:

      @Html.Raw(item.SkillsSet)

      NB: You'll need to make sure the rest of the string is properly HTML-encoded to ensure it displays correctly and to avoid the potential for a persisted cross-site scripting vulnerability.


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      W 1 Reply Last reply
      0
      • Richard DeemingR Richard Deeming

        Try using the Html.Raw helper method to indicate that the string should not be HTML-encoded:

        @Html.Raw(item.SkillsSet)

        NB: You'll need to make sure the rest of the string is properly HTML-encoded to ensure it displays correctly and to avoid the potential for a persisted cross-site scripting vulnerability.


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        W Offline
        W Offline
        Wiep Corbier
        wrote on last edited by
        #3

        Didn't work but you put me in the right direction Richard. Many thanks!!! I found the solution in a minute after trying your tip: How do I render raw HTML in Blazor? | Blazor FAQ | Syncfusion[^]

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups