我要验证下拉框的值用哪个验证控件

来源:百度知道 编辑:UC知道 时间:2024/06/30 14:01:56
页面上一个button 一个下拉框 下拉框有 〈请选择〉〈a〉<b> <c>这几个选项 如果选 请选择 点button 页面不刷新 选择a,b,c 点button页面刷新
应该用哪个验证控件 ,还要设置哪些属性

不需要button按钮
aspx页面:
<asp:DropDownList runat="server" ID="ddlT" OnSelectedIndexChanged="ddlT_SelectedIndexChanged" AutoPostBack=true>
<asp:ListItem>请选择</asp:ListItem>
<asp:ListItem>a</asp:ListItem>
<asp:ListItem>b</asp:ListItem>
<asp:ListItem>c</asp:ListItem>
</asp:DropDownList>

cs页面:
protected void ddlT_SelectedIndexChanged(object sender, EventArgs e)
{
if (ddlT.Text != "请选择")
{
//刷新页面
}
}

直接在下拉框的selectValuedChanged()事件里面写你的代码就行了

在ajax中有个updatePanel控件就是防止页面刷新的

DropDownList1

在Button1_Click事件中

//取到当前选择项的 Value 值
string xxx = DropDownLost1.text;

//
if(xxx。Equals(" 〈请选择〉的 VALUE 值"))
{
//说明是选择了〈请选择〉这项
//干你需要的工作(页面不刷新)
}