Click here to Skip to main content
15,886,963 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
my question there are two radio buttons .when i check one radio button it should shows some of the text fields and other fiels should be invisible.if i click another radio button the invisible field should visible.plz find a solution.i can't do this.what is the code and logic written is aspx.cs page?
Posted
Comments
Sushil Mate 16-Oct-12 2:36am    
i'll leave it to another cp'ians to answer your question. :)
skuanr 16-Oct-12 2:40am    
ok

There is an event called "Checked" use it

http://www.w3schools.com/aspnet/control_radiobutton.asp[^]
 
Share this answer
 
if (chkRadio1.checked == true) {
txttextBox.visible=true;
}
else
{
txttextBox.visible=false;
}
 
Share this answer
 
Comments
skuanr 16-Oct-12 2:47am    
i hv already tried that code.this is not a solution.
skuanr 16-Oct-12 2:51am    
after page_load event there are radio button like internal and semesters.i want that when i click on internal then it shows me the text field like subject,total mark,secure mark.then when i click on semester then it should shows file upload option others are invisible.
Hi,

You should group both the radio button and then on click event method you can set display or visible property to true or false as per your need.
 
Share this answer
 
Comments
skuanr 16-Oct-12 2:56am    
Tried that ,but not working.anyway thanx.
skuanr 16-Oct-12 3:19am    
Hi,
I have got solution.answer is auto postback property to be true.
Use the following code
C#
<asp:radiobuttonlist id="rbShowOrHide" runat="server" autopostback="True" cssclass="fontcolor" onselectedindexchanged="rbShowOrHide_SelectedIndexChanged" repeatdirection="Horizontal" width="100%" xmlns:asp="#unknown">
                     
    <asp:listitem value="hide">hide</asp:listitem>
    <asp:listitem selected="True" value="show">show</asp:listitem>
 </asp:radiobuttonlist>


and .cs page code is
C#
protected void rbShowOrHide_SelectedIndexChanged(object sender, EventArgs e)
       {
           if (rbShowOrHide.SelectedValue == "show")
           {
               txtVisibleOrNon.Visible = true;
           }
           else
               txtVisibleOrNon.Visible = false;
       }


may be its help u..
Continue with your coding fun :-)
 
Share this answer
 
v2
Comments
Member 11413286 21-Feb-15 10:22am    
on clicking a radiobutton should display in dropdown or listbox...pls help me

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900