locked
Ajax Control toolkit ComboBox MaxDropDownItems setting has no effect RRS feed

  • Question

  • User843711734 posted

    I am attempting to limit the number of visible list items in an Ajax ComboBox control.  I thought the MaxDropDownItems property was supposed to accomplish this for me but has no effect on the control when rendered in a browser.  The following code snippet shows the properties I have defined for the control:

    <ajaxToolkit:ComboBox ID="ComboBox1" runat="server"

                  DataSourceID="SqlDataSource1"

                  DataTextField="FullName"

                  DataValueField="Record_ID#"

                  OnSelectedIndexChanged="ComboBox1_SelectedIndexChanged"

                  AutoCompleteMode="Suggest"

                  AutoPostBack="True"

                  ClientIDMode="Static"

                  Height="22px"

                  TabIndex="1"

                  MaxDropDownItems="5">

    </ajaxToolkit:ComboBox>

    It does not seem to matter what what value I use for the MaxDropDownItems property.  There is no effect on the rendered control. 

    Suggestions would be greatly appreciated.

    Friday, February 5, 2016 6:37 PM

Answers

  • User2103319870 posted

    It does not seem to matter what what value I use for the MaxDropDownItems property.  There is no effect on the rendered control. 

    Suggestions would be greatly appreciated.

    You can try assigning a css to the dropdown of combobox and restrict its height to 150px or any size which you want.

    Sample Code

     <style>
                .ajax__combobox_itemlist {
                    height: 150px !important;
                    overflow-y: scroll !important;
                }
            </style>
            <ajaxToolkit:ComboBox ID="ComboBox2" runat="server"
                DataSourceID="SqlDataSource1"
                DataTextField="FullName"
                DataValueField="Record_ID#"
                OnSelectedIndexChanged="ComboBox1_SelectedIndexChanged"
                AutoCompleteMode="Suggest"
                AutoPostBack="True"
                ClientIDMode="Static"
                Height="22px"
                TabIndex="1"
                MaxDropDownItems="5">
            </ajaxToolkit:ComboBox>

    You can get the css class details from here

    Source URl

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, February 5, 2016 8:24 PM

All replies

  • User2103319870 posted

    It does not seem to matter what what value I use for the MaxDropDownItems property.  There is no effect on the rendered control. 

    Suggestions would be greatly appreciated.

    You can try assigning a css to the dropdown of combobox and restrict its height to 150px or any size which you want.

    Sample Code

     <style>
                .ajax__combobox_itemlist {
                    height: 150px !important;
                    overflow-y: scroll !important;
                }
            </style>
            <ajaxToolkit:ComboBox ID="ComboBox2" runat="server"
                DataSourceID="SqlDataSource1"
                DataTextField="FullName"
                DataValueField="Record_ID#"
                OnSelectedIndexChanged="ComboBox1_SelectedIndexChanged"
                AutoCompleteMode="Suggest"
                AutoPostBack="True"
                ClientIDMode="Static"
                Height="22px"
                TabIndex="1"
                MaxDropDownItems="5">
            </ajaxToolkit:ComboBox>

    You can get the css class details from here

    Source URl

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, February 5, 2016 8:24 PM
  • User843711734 posted

    Thank you.  It seems as though the overflow from the dropdown list was the issue all along.  Changing he MaxDropDownItems property still does not seem to have any effect on the numer of visible items but I can live with it.  Your modification of the overflow in the <style> snippet saved the day for me!

    Sunday, February 7, 2016 3:03 PM