This is a migrated thread and some comments may be shown as answers.

[Solved] Increase the width of DropDownList

2 Answers 130 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Sabuj
Top achievements
Rank 1
Sabuj asked on 30 Jan 2012, 11:06 PM
I think this a simple problem but cant figure out. In my project I need to increase the width of the dropdownlist. How do i do it?
Here is my Dropdownlist
@Html.Telerik.DropDownListFor(Function(model) model.OrderEntityID).BindTo(New SelectList(ViewBag.OrderEntities, "OrderEntityID", "Name")).ClientEvents(Sub(events) events.OnChange("orderEntityID_OnChange"))

Have tried .DropDownHtmlAttributes( new { style = "width = 150px; font-size: 10px; height: 70px;" } )...
  

2 Answers, 1 is accepted

Sort by
0
Accepted
Georgi Tunev
Telerik team
answered on 31 Jan 2012, 10:11 AM
Hello Sabuj,

With DropDownHtmlAttributes you are controlling the items' list only, not the whole dropdown. In addition, there is no width= 150px syntax in CSS, it should be widht:150px
Try
@(Html.Telerik().DropDownList()
    .Name("someList")
    .Items(item =>
            {
                item.Add().Text("Item1").Value("1").Selected(true);
                item.Add().Text("Item2").Value("2");
                item.Add().Text("Item3").Value("3");
            })
            //set the width of the items list only 
            .DropDownHtmlAttributes(new { style = string.Format("width:{0}px", 200) })
            //set the width of the whole dropdown (incl. the main input)
            .HtmlAttributes(new { style = string.Format("width:{0}px", 400) })
)


All the best,
Georgi Tunev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Sabuj
Top achievements
Rank 1
answered on 01 Feb 2012, 08:38 PM
Hello Georgi,
Thank you much for your reply.
That helped.

  
Tags
General Discussions
Asked by
Sabuj
Top achievements
Rank 1
Answers by
Georgi Tunev
Telerik team
Sabuj
Top achievements
Rank 1
Share this question
or