How to create a javascript string in razor

前端 未结 3 565
情书的邮戳
情书的邮戳 2021-02-18 22:51

I have seen some posts regarding this topic and a few blogs, but none seem to mention the output I\'m getting.

What I want is to generate a google maps map with informat

3条回答
  •  無奈伤痛
    2021-02-18 23:34

    I believe you could do most of the heavy lifting in .net and leverage Html.Raw to transform the object for you:

    @{
        var myObj = Model.Select(i => new {
            item.Gebouwnaam,
            item.LocatieLatitude.ToString().Replace(",", "."),
            item.LocatieLongitude.ToString().Replace(",", "."),
            item.Plaats,
            item.Gebruiksfunctie,
            item.Licentiehouder,
            item.rating }).ToArray();
    }
    
    
    

    Since it's touched on in this question, HttpUtility.JavaScriptStringEncode() comes in really handy for strings containing newline characters:

    @{ var myNetString = "Hi,\r\nMy name is Joe\r\nAnd I work in a button factory"; }
    
    
    

提交回复
热议问题