在@html.dropdownlist中包装文本 [英] Wrap text inside @html.dropdownlist

查看:57
本文介绍了在@html.dropdownlist中包装文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要包含超出下拉列表宽度的文本,并显示下拉列表中所有项目的工具提示

解决方案

1.在您的控制器中代码,您必须通过测试超过字符长度的字符串大小来操作下拉列表中的项目(您应该使用更大的值测试,如MMMMM ... M)然后最终将得到列表与LT; SelectListItem> 列表已准备好在您的模型中用作属性。最后在您的视图中,您可以使用

 @ Html.DropDownList(myDropDownList,Model.MyList,new {@class =dropDownList})来呈现它。 / pre> 

并指定一个类(在我的示例中名为dropDownList),用于为列表设置至少具有适当字体和字体大小的样式。



2.关于如何在这里显示工具提示是解决方案:

- 在控制器中填充一个字符串,其中包含需要文本的文本以显示为工具提示并将其添加为您的模型的属性;

- 使用此信息,通过使用jQuery将其显示为工具提示,如下一个链接所示:示例 [ ^ ]

I need to wrap the text that exceeds the width of the dropdownlist as well as show a tooltip for all items in the dropdownlist

解决方案

1.In your controller code, you have to manipulate your items from the dropdownlist by testing on the string size that exceed a maxim length of chars (you should test with bigger values like "MMMMM...M") then in the end will result a List<SelectListItem> list ready to be used in your Model as property. Finally in your view you can render it by using

@Html.DropDownList("myDropDownList", Model.MyList, new { @class ="dropDownList" })


and by specifying a class (named "dropDownList" in my example) for styling the list with a proper font and font size at least.

2.Regarding how to show the tooltip here is the solution:
-populate in your controller a string with the text needed text to show as tooltip and add it as a property to your model;
-use this info as to show it as tooltip by using jQuery as is indicated in the next link: Example[^]


这篇关于在@html.dropdownlist中包装文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆