views:

318

answers:

1
<asp:TextBox ID="TextBox5" runat="server" Height="30px" Width="68px"></asp:TextBox>
<ajaxToolkit:DropDownExtender ID="TextBox5_DropDownExtender" runat="server" 
DynamicServicePath="" Enabled="True" TargetControlID="TextBox5">
</ajaxToolkit:DropDownExtender>

    //this.TextBox5_DropDownExtender ????
    YearList.Items.Add(DateTime.Today.AddYears(-i).ToString("yyyy"));

Question : where is items for this DropDownExtender ?

+1  A: 

There's a property called DropDownControlID on the extender. Point that to a panel and put your items there. Something like this:

<asp:TextBox ID="TextBox5" runat="server" Height="30px" Width="68px" />
<ajaxToolkit:DropDownExtender ID="TextBox5_DropDownExtender" runat="server" 
 DynamicServicePath="" Enabled="True" TargetControlID="TextBox5"
 DropDownControlID="pnlItems" />

<asp:Panel ID="pnlItems" runat="server" BorderColor="Black" BorderWidth="1">
   <asp:BulletedList ID="YearList" runat="server" />
</asp:Panel>

In code, add items to YearList.

Nick Craver
ok ... looking like weird control :S
nCdy
@nCdy - See here for a full page example: http://asp-net-example.blogspot.com/2009/12/ajax-dropdownextender-how-to-use.html
Nick Craver
but this list seems like not clickable :(
nCdy
@nCdy - The `ajaxToolkit:DropDownExtender` doesn't do click events, that's javascript or server-side script you rig up yourself. Maybe you're thinking of the AutoCompleteExtender? http://www.asp.net/AJAX/AjaxControlToolkit/Samples/AutoComplete/AutoComplete.aspx
Nick Craver
so there is no default combobox ? :-/
nCdy