<asp:DropDownList AccessKey="string" AppendDataBoundItems="True|False" AutoPostBack="True|False" BackColor="color name|#dddddd" BorderColor="color name|#dddddd" BorderStyle="NotSet|None|Dotted|Dashed|Solid|Double|Groove|Ridge| Inset|Outset" BorderWidth="size" CausesValidation="True|False" CssClass="string" DataMember="string" DataSource="string" DataSourceID="string" DataTextField="string" DataTextFormatString="string" DataValueField="string" Enabled="True|False" EnableTheming="True|False" EnableViewState="True|False" Font-Bold="True|False" Font-Italic="True|False" Font-Names="string" Font-Overline="True|False" Font-Size="string|Smaller|Larger|XX-Small|X-Small|Small|Medium| Large|X-Large|XX-Large" Font-Strikeout="True|False" Font-Underline="True|False" ForeColor="color name|#dddddd" Height="size" ID="string" OnDataBinding="DataBinding event handler" OnDataBound="DataBound event handler" OnDisposed="Disposed event handler" OnInit="Init event handler" OnLoad="Load event handler" OnPreRender="PreRender event handler" OnSelectedIndexChanged="SelectedIndexChanged event handler" OnTextChanged="TextChanged event handler" OnUnload="Unload event handler" runat="server" SelectedIndex="integer" SelectedValue="string" SkinID="string" Style="string" TabIndex="integer" ToolTip="string" ValidationGroup="string" Visible="True|False" Width="size" > <asp:ListItem Enabled="True|False" Selected="True|False" Text="string" Value="string" /> </asp:DropDownList>
<%@ Page Language="C#" Debug="true" %> <script runat="server"> void btnSubmit_OnClick(object sender, EventArgs e) { this.lblText1.Text = this.DropDownList1.SelectedItem.Text; } void DropDownList2_SelectedIndexChanged(object sender, EventArgs e) { this.lblText2.Text = this.DropDownList2.SelectedItem.Text; } </script> <html> <head> </head> <body> <form runat="server"> <asp:DropDownList id="DropDownList1" runat="server"> <asp:ListItem>Items 1</asp:ListItem> <asp:ListItem>Items 2</asp:ListItem> <asp:ListItem>Items 3</asp:ListItem> <asp:ListItem>Items 4</asp:ListItem> <asp:ListItem>Items 5</asp:ListItem> </asp:DropDownList> <asp:DropDownList id="DropDownList2" OnSelectedIndexChanged="DropDownList2_SelectedIndexChanged" AutoPostBack="True" runat="server"> <asp:ListItem>Items 1</asp:ListItem> <asp:ListItem>Items 2</asp:ListItem> <asp:ListItem>Items 3</asp:ListItem> <asp:ListItem>Items 4</asp:ListItem> <asp:ListItem>Items 5</asp:ListItem> </asp:DropDownList> <br /><br /> <asp:Button id="btnSubmit" onclick="btnSubmit_OnClick" runat="server" Text="Submit"></asp:Button> <br /> <hr /> <asp:Label id="lblText1" runat="server"></asp:Label> <br> <asp:Label id="lblText2" runat="server"></asp:Label> <br /> </form> </body> </html>
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท