2011-08-02 8 views
0

私は3つのラジオボタンとテキストボックスを持つユーザーコントロールを持っています。 RB1を選択すると、テキストボックスが表示されます。残りの2つのオプションについては、テキストボックスを非表示にします。ラジオボタンの属性を動的に追加します

<asp:RadioButton ID="rbAPL" runat="server" Checked="true" CssClass="tablecelldata" 
       GroupName="ServiceType" Text="Testing of Animal Pathogens & Veterinary Biologics" /><br /> 
    <asp:RadioButton ID="rbVPHL" runat="server" CssClass="tablecelldata" GroupName="ServiceType" 
       Text="Food Testing and Export Health Certification (Veterinary Health Certificate for Meat, Fish & Dairy Products)" /><br /> 
    <asp:RadioButton ID="rbPHL" runat="server" CssClass="tablecelldata" GroupName="ServiceType" 
       Text="Plant Health Diagnosis Services" /> 

そして、私は動的にテキストボックスを表示または非表示にするラジオボタンの属性を設定したいテキストボックス

<asp:TextBox ID="tbxApplicationRefNo" runat="server" Width="350px"></asp:TextBox> 

。どうすればいいですか?

ご返信いただきありがとうございます!

+0

あなたはJavaScriptの方ではなく、サーバー側でやりたいと思われます。 – Oded

+0

あなたは大歓迎です!私はあなたが私の答えを投票すると嬉しいだろう:)ありがとう。 – vladimir77

答えて

0

1 jqueryのを使用して表示/非表示の場合はラジオボタンのJS-のonclickイベント

2にハンドラを追加します(例: "$( '#IDは')ショー();")

3ペイ最初は注意が必要TextBoxは見えないcos RB1はチェクシングされています

<asp:RadioButton ID="rbAPL" runat="server" Checked="true" CssClass="tablecelldata" GroupName="ServiceType" Text="Testing of Animal Pathogens & Veterinary Biologics" onclick='<%# string.Format("$(&#39;#{0}&#39;).hide();", tbxApplicationRefNo.ClientID) %>' /> 
<br /> 
<asp:RadioButton ID="rbVPHL" runat="server" CssClass="tablecelldata" GroupName="ServiceType" Text="Food Testing and Export Health Certification (Veterinary Health Certificate for Meat, Fish & Dairy Products)" onclick='<%# string.Format("$(&#39;#{0}&#39;).show();", tbxApplicationRefNo.ClientID) %>' /> 
<br /> 
<asp:RadioButton ID="rbPHL" runat="server" CssClass="tablecelldata" GroupName="ServiceType" Text="Plant Health Diagnosis Services" onclick='<%# string.Format("$(&#39;#{0}&#39;).show();", tbxApplicationRefNo.ClientID) %>' /> 
<br /> 
<asp:TextBox style="display:none" ID="tbxApplicationRefNo" runat="server" Width="350px" Text="hello :)"></asp:TextBox> 
+0

ありがとうございましたvladimir77 –

0

私は背後にあるコードではこのような何かをするだろう。それがクリックされたとき

public void rbAPL_CheckedChanged(object sender, EventArgs e) 
{ 
    RadioButton button = sender as RadioButton; 

    if (button.Checked) 
    { 
     tbxApplicationRefNo.Visible = true; 
    } 
} 

は可視としてテキストボックスを設定します。

関連する問題