Loading...

DropDownList


DropDownList Example

Select a background color for days in the calendar.

<2021年11月>
週日週一週二週三週四週五週六
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

Background color:
@inherits ControlComponent
<p>Select a background color for days in the calendar.</p>

<asp.Calendar @ref="this.calendar" ShowGridLines="true" ShowTitle="true" />

<br />

<table cellpadding="5">
                                            <tr>
                                            <td>
            Background color:
                                            </td>
                                            </tr>
                                            <tr>
                                            <td>
                                            <asp.DropDownList @ref="this.colorList"
                                            AutoPostBack="true"
                                            OnSelectedIndexChanged="this.Selection_Change">
                                            <asp.ListItem Selected="true" Value="White">White</asp.ListItem>
                                            <asp.ListItem Value="Silver">Silver</asp.ListItem>
                                            <asp.ListItem Value="DarkGray">Dark Gray</asp.ListItem>
                                            <asp.ListItem Value="Khaki">Khaki</asp.ListItem>
                                            <asp.ListItem Value="DarkKhaki">Dark Khaki</asp.ListItem>
                                            </asp.DropDownList>
                                            </td>
                                            </tr>
</table>

@code {
                                            private Calendar calendar;
                                            private DropDownList colorList;

                                            protected void Selection_Change(object sender, EventArgs e)
    {
                                            // Set the background color for days in the Calendar control
                                            // based on the value selected by the user from the
                                            // DropDownList control.
        calendar.DayStyle.BackColor =
            System.Drawing.Color.FromName(colorList.SelectedItem.Value);
    }
}
DropDownList Data Binding Example

Select a background color for days in the calendar.

<2021年11月>
週日週一週二週三週四週五週六
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

Background color:
@inherits ControlComponent
@inject HttpClient Http
<p>Select a background color for days in the calendar.</p>

<asp.Calendar @ref="this.calendar" ShowGridLines="true" ShowTitle="true" />

<br />

<table cellpadding="5">
                                            <tr>
                                            <td>
            Background color:
                                            </td>
                                            </tr>
                                            <tr>
                                            <td>
                                            <asp.DropDownList @ref="this.colorList"
                                            AutoPostBack="true" DataSourceID="FreeDataSource1"
                                            DataTextField="ColorTextField"
                                            DataValueField="ColorValueField"
                                            OnSelectedIndexChanged="this.Selection_Change">
                                            </asp.DropDownList>

                                            <asp.FreeDataSource ID="FreeDataSource1" OnExecuteSelected="sender => this.colors" />
                                            </td>
                                            </tr>
</table>

@code {
                                            private Color[] colors;
                                            private Calendar calendar;
                                            private DropDownList colorList;

                                            protected override async Task OnInitializedAsync()
    {
        colors = await Http.GetFromJsonAsync<Color[]>("sample-data/colors.json");
    }

                                            protected void Selection_Change(object sender, EventArgs e)
    {
                                            // Set the background color for days in the Calendar control
                                            // based on the value selected by the user from the
                                            // DropDownList control.
        calendar.DayStyle.BackColor =
            System.Drawing.Color.FromName(colorList.SelectedItem.Value);
    }

                                            public class Color
    {
                                            public string ColorTextField { get; set; }

                                            public string ColorValueField { get; set; }
    }
}

DropDownList Metadata
Name Type Kind
AccessKey String Parameter
AppendDataBoundItems Boolean Parameter
Attributes IReadOnlyDictionary Parameter
AutoPostBack Boolean Parameter
BackColor String Parameter
BorderColor String Parameter
BorderStyle BorderStyle Parameter
BorderWidth String Parameter
CausesValidation Boolean Parameter
ClientIDMode ClientIDMode Parameter
CssClass String Parameter
DataMember String Parameter
DataSourceID String Parameter
DataTextField String Parameter
DataTextFormatString String Parameter
DataValueField String Parameter
Enabled Boolean Parameter
FontBold Boolean Parameter
FontItalic Boolean Parameter
FontNames String Parameter
FontOverline Boolean Parameter
FontSize String Parameter
FontStrikeout Boolean Parameter
FontUnderline Boolean Parameter
ForeColor String Parameter
Height String Parameter
ID String Parameter
SelectedValue String Parameter
Style String Parameter
TabIndex Int16 Parameter
ToolTip String Parameter
ValidationGroup String Parameter
Visible Boolean Parameter
Width String Parameter
OnCallingDataMethods CallingDataMethodsEventHandler Event
OnCreatingModelDataSource CreatingModelDataSourceEventHandler Event
OnDataBinding EventHandler Event
OnDataBound EventHandler Event
OnDisposed EventHandler Event
OnInit EventHandler Event
OnLoad EventHandler Event
OnPreRender EventHandler Event
OnSelectedIndexChanged EventHandler Event
OnTextChanged EventHandler Event
OnUnload EventHandler Event
Attributes IReadOnlyDictionary Parameter
Enabled Boolean Parameter
Selected Boolean Parameter
Text String Parameter
Value String Parameter
Copyright © 2024 Jurio li All rights reserved.
An unhandled error has occurred. Reload 🗙