如何在asp.net c#中将auto width属性设置为下拉列表 [英] How to set the auto width property to dropdown list in asp.net c#

查看:55
本文介绍了如何在asp.net c#中将auto width属性设置为下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我使用c#平台在asp.net下工作,整个项目的设计已经完成,现在我想将自动宽度应用于下拉列表,例如,下拉列表应该适合小字符串和大字符串也可以帮助我。

Hi,
I working under asp.net with c# platform, the total project's design was completed, now i want to apply the autowidth to dropdownlist, forexample, dropdown should fit for small string and for large string also, can u help me regarding this.

推荐答案

只需从DropdownList中删除宽度,默认情况下它将是auto。确保任何其他CSS不会影响它。如果是这种情况,您只需添加 style =width:auto;



问候..
Just remove width from DropdownList and by default it will be auto. Make sure any other CSS don't affect it. If it's the case, you can simply add style="width:auto;".

Regards..


使用这个



1.添加style = width:auto;进入ASP.NET webcontrol,如问题中所述。



2.添加element.Attributes.Add('style','width:auto');在代码背后。通常它与选项号1相同,只是它从后面的代码中添加。但是选项1似乎更好,因为它不会混淆演示与代码背后,并且更改演示文稿不需要重新编译程序。



3.删除宽度ASP.NET控件的属性。如果未指定Width属性,则将其设置为auto。但是,如果有任何可能影响行为的CSS规则,我们需要小心,例如我们在CSS文件中指定输入
use this

1. Adding the style=width:auto; into the ASP.NET webcontrol, as mentioned in the question.

2. Adding element.Attributes.Add('style', 'width:auto'); in the code behind. Generally it is the same as option number 1, just that it's added from code behind. But option 1 seems to be better because it does not mix presentation with code behind, and changing the presentation does not require recompiling of the program.

3. Remove the Width property for the ASP.NET control. If the Width property is not specified, it will be set as auto. But here we need to be careful if there is any CSS rule that may affect the behavior, for example we specify input in the CSS file


这篇关于如何在asp.net c#中将auto width属性设置为下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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