vinodkumarnie
Попробуйте ниже..
Код C# ниже..
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
if (DropDownList22.SelectedItem.Text == "IT")
{
Button1.CausesValidation = true;
}
else
{
Button1.CausesValidation = false;
}
}
}
protected void DropDownList22_SelectedIndexChanged(object sender, EventArgs e)
{
if (DropDownList22.SelectedItem.Text == "IT")
{
Button1.CausesValidation = true;
}
else
{
Button1.CausesValidation = false;
}
}
HTML-код ниже..
<asp:DropDownList ID="DropDownList22" runat="server" OnSelectedIndexChanged="DropDownList22_SelectedIndexChanged"
AutoPostBack="true">
<asp:ListItem>IT</asp:ListItem>
<asp:ListItem>Admin</asp:ListItem>
<asp:ListItem>HR</asp:ListItem>
</asp:DropDownList>
<asp:TextBox ID="TextBox32" runat="server" AutoPostBack="true" OnTextChanged="TextBox32_TextChanged"></asp:TextBox>
<asp:RequiredFieldValidator ID="chkDateReturn" runat="server" ControlToValidate="TextBox32"
ErrorMessage="Must select the return date"></asp:RequiredFieldValidator>
<asp:Button ID="Button1" runat="server" Text="Button" CausesValidation="false" />
Надеюсь, это вам поможет..