开发者

How to prevent a drop down box from resizing

开发者 https://www.devze.com 2023-03-23 11:32 出处:网络
I\'m using C# and jquery.I have a dropdown box that has 20 elements in it.It is sized according to the text of the largest element.

I'm using C# and jquery. I have a dropdown box that has 20 elements in it. It is sized according to the text of the largest element.

I have a checkbox. When the user clicks the checkbox开发者_JAVA技巧, all of the selections are removed from the dropdown box. The problem is that when this happens, the box gets smaller and looks kind of awkward.

How do I prevent this from happening?


Set the Width property of the ASP.NET Control, or use CSS to set the width client-side. If you want to dynamically determine the width, do something like this:

$(function() {
    var width = $('#ddlID').width();
    $('#ddlID').css('width', width);
});

Here's a working example: http://jsfiddle.net/FishBasketGordo/89nS4/


atleast have the default set for the check box like "Please Select" and then append the dynamic content on button select and in css just write this select{width: 300px} some fix width

yourcombo.Items.Insert(0, "Select");

and add the above answer to make it more efficient

0

精彩评论

暂无评论...
验证码 换一张
取 消