drop down list width according to the text size

Last post 10-16-2008 2:56 PM by budugu. 1 replies.

Sort Posts:

  • drop down list width according to the text size

    10-16-2008, 1:34 PM
    • Member
      131 point Member
    • aspxkid
    • Member since 11-27-2006, 9:04 AM
    • Posts 65

    I have a dropdownlist :

    <asp:DropDownList ID="ddl" runat="server" normalWidth="130px" width="130px" onmouseover ="expandDropDownList(this);" onclick="expandDropDownList(this);" onfocus="expandDropDownList(this);" onblur="collapseDropDownList(this);" onchange="collapseDropDownList(this);"></asp:DropDownList>

    and the javascript is

    function expandDropDownList(elementRef)

    {

    elementRef.style.width = 'auto';

    }

    function collapseDropDownList(elementRef)

    {

    elementRef.style.width = elementRef.normalWidth;

    }

    what happens is when i move the mouse over the control the width gets increased. but when i dont select anything and comeout, the width remains the same ..expanded. so i wrote onmouseleave event to collapse the width. because of this when i am trying to select an item in the ddl, the size shrinks automatically . and this looks awkward. can someone help

  • Re: drop down list width according to the text size

    10-16-2008, 2:56 PM
    Answer
    • All-Star
      24,806 point All-Star
    • budugu
    • Member since 01-12-2006, 2:15 PM
    • North Carolina
    • Posts 3,697

    may be this code will help you..

    http://forums.asp.net/t/1042109.aspx

    Vijay Kodali || My Blog


    "Don't be afraid to be wrong; otherwise you'll never be right."
Page 1 of 1 (2 items)