Is there a way to concatenate strings in html attributes?

后端 未结 4 1943
名媛妹妹
名媛妹妹 2021-02-05 04:51

I\'m using MVC3 and I wanted to use a partial view to create dynamic DOM elements. This is my current partial view:

@model MVCApp.ViewModels.TitlesViewModel

<         


        
4条回答
  •  感情败类
    2021-02-05 05:10

    You want:

    Razor will recognise the @ as the start of code, execute it and render the results in place in the attribute.

    Edit:

    This didn't work well as a comment, but here's a line from one of my Razor controls:

    
    

    Try adding a hyphen (-) before the @. It's quite possible that Razor thinks it's an e-mail address and leaving it alone!

提交回复
热议问题