ASP.NET MVC 3 Razor Syntax - Casting

前端 未结 2 475
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-16 10:49

So, simple question really. :)

I had this following code with ASPX View Engine:

<%: ((City)Model.Location).Name %&g         


        
相关标签:
2条回答
  • 2020-12-16 11:21

    Also, for slightly easier reading...

    <strong>@( (Model.Location as City).Name )</strong>
    
    0 讨论(0)
  • 2020-12-16 11:33

    Does <strong>@(((City)Model.Location).Name)</strong> work? I think it's thinking the expression contained within @() is closed.

    0 讨论(0)
提交回复
热议问题