こんにちは問題検証
2 Radio buttons 1 Text Box, 1 Required field validator and a button
を次のように私はいくつかのコントロールで自分のフォームを持っているすべての私は1つのラジオボタンが選択されている場合、私は有効になりますように、私のサンプルコードを書いたかを発射しながら、私が持っているテキストボックスを無効にします。
私は、利用可能なテキストボックスに設定された必須のフィールドバリデーターを持っています。コントロールが無効になっていた時に、今私は必要なものを私はこのために検証を実行する必要はありませんされ、それは
サンプルコード
protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
{
TextBox1.Enabled = true;
}
protected void RadioButton2_CheckedChanged(object sender, EventArgs e)
{
TextBox1.Enabled = false;
}
マイデザイン
<form id="form1" runat="server">
<div>
<asp:RadioButton ID="RadioButton1" runat="server" AutoPostBack="True" GroupName="g"
OnCheckedChanged="RadioButton1_CheckedChanged" ValidationGroup="g1" />
<asp:RadioButton ID="RadioButton2" runat="server" AutoPostBack="True" GroupName="g"
OnCheckedChanged="RadioButton2_CheckedChanged" />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1"
ErrorMessage="RequiredFieldValidator" ValidationGroup="g1"></asp:RequiredFieldValidator>
<asp:Button ID="Button1" runat="server" Text="Button" ValidationGroup="g1" /></div>
</form>
検証SHOULDを行うことが可能ですコントロールを有効にしたときにのみ適用されます
多くはstackoverflowの自体にあります。このhttp://www.google.co.in/search?gcx=c&sourceid=chrome&ie=UTF-8&q=disable+required+field+validator+in+asp.net+%2B+stackoverflow – sansknwoledge