Questions tagged «mvchtmlstring»

4
如何串联多个MvcHtmlString实例
由于在MSDN中找到此信息,我对如何连接MvcHtmlString实例有一些疑问: MvcHtmlString类表示一个HTML编码的字符串,不应再次对其进行编码 使用以下代码时,我是否会冒险两次对字符串进行HTML编码: var label = Html.LabelFor(model => model.Email); var textbox = Html.TextBoxFor(model => model.Email); var validation = Html.ValidationMessageFor(model => model.Email); var result = MvcHtmlString.Create( label.ToString() + textbox.ToString() + validation.ToString()); (请注意:这应该纳入HtmlHelper扩展方法中,以减少视图中的代码重复)。
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.