How to retain spaces in DropDownList - ASP.net MVC Razor views

前端 未结 1 1827
失恋的感觉
失恋的感觉 2020-12-01 06:22

I\'m binding my model in the following way in the view:

<%=Html.DropDownList(\"SelectedItem\",new SelectList(Model.MyItems,\"ItemId\",\"ItemName\")) %>         


        
相关标签:
1条回答
  • 2020-12-01 07:19

    nbsp in html corresponds to "\xA0" as a C# string, so use this instead of spaces, when HTML encoded it will produce nbsp

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