我有一个带有 Autopostback 属性的下拉列表,我想要,如果选择Select Week
选项,那么它不应该回发,否则它应该回发。下面是函数。
JAVASCRIPT
function OnWeekChange() {
var value = $("#DropDownListWeeks option:selected").val();
if (value == "-1")
return false;
else return true;
}
ASPX
<asp:DropDownList ID="DropDownListWeeks" runat="server" Height="23px" Width="252px"
OnSelectedIndexChanged="DropDownListWeeks_SelectedIndexChanged" AutoPostBack="true" ClientIDMode="Static"
AppendDataBoundItems="true" onchange="return OnWeekChange();">
</asp:DropDownList>
。CS
weeks = client.GetWeeks(true);
foreach (Roaster_Week week in weeks)
{
//Add weeks in the dropdowns with formatting
DropDownListWeeks.Items.Add(new ListItem(string.Format("{0:MMM d, yyyy}", week.StartDate) + " - " + string.Format("{0:MMM d, yyyy}", week.EndDate),week.WeekID.ToString()));
}
client.Close();
DropDownListWeeks.Items.Insert(0, new ListItem("Select Week","-1"));
在我的情况下,即使我选择了除-1
. 您能否为我的方案提供适当的解决方案。Jquery