標籤在我選擇dropdownlist後工作,我試圖禁用其他下拉菜單。如何禁用<select>標籤(html下拉)使用asp.net下拉列表
但問題是,只有在點擊提交按鈕時纔會觸發注意我的提交按鈕還沒有代碼。
下面是我的一些代碼
在Option.aspx(客戶端)
<select id="ddlgames" class="ddlgame" runat="server">
<option value="" selected="selected">Select One</option>
<option value="BasketBall">Basket Ball</option>
<option value="VolleyBall">Volley Ball</option>
<option value="FootBall">Foot Ball</option>
</select>
<asp:UpdatePanel ID="Update" runat="server">
<ContentTemplate>
<asp:DropDownListID="ddlPlayer"CssClass="Player" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlPlayer_SelectedIndexChanged">
</asp:DropDownList>
<asp:Label ID="lblcomment" runat="server" Text="">
</asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
<asp:Button ID="Submit" runat="server" OnClick="Submit_Click" Text="Submit" />
代碼隱藏
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ddlPlayer.Items.Add(new ListItem { Text = "Player", Value = "Y" });
ddlPlayer.Items.Add(new ListItem { Text = "Non Player", Value = "N" });
}
}
protected void ddlNameOfReport_SelectedIndexChanged(object sender, EventArgs e)
{
if (ddlplayer.SelectedValue == "N")
{
ddlgames.Disabled = true;
lblcomment.Text = "Games option disabled";
}
else
{
ddlgames.Disabled = true;
lblcomment.Text = "Games option enabled";
}
}
protected void Submit_Click(object sender, EventArgs e)
{
}
遺憾的錯誤語法:)
ddlNameOfReport我不能看到它在你的HTML希望它會ddlPlayer – Seminda 2014-09-01 03:18:01