Escape @ character in razor view engine

后端 未结 15 2078
梦谈多话
梦谈多话 2020-11-22 07:55

I am creating a sample ASP.NET MVC 3 site using Razor as view engine. The razor syntax starts with @ character e.g. @RenderBody(). If I write @test

15条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-22 08:43

    Actually @ should be used with the Razor syntax Keywords or to the variable/model to bind a Value.

    For Eg: if test is assigned with value i.e @ { var test = "ABC" } then you can get the value by settings as @test anywhere is cshtml page in html part. otherwise, simple use as @Html.DisplayName("test")

提交回复
热议问题