Click here to Skip to main content
15,907,874 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I have one form for filling details and in this form i have one radio button...On selectedindexchange, if value is No then nothing happen and if value is Yes then i want to show a small form(name2) to user.
ASP.NET
<table>
<tr>
<td>
Are you known by any other names or aliases?*: 
<asp:RadioButtonList ID="RadioButtonList1" runat="server"    RepeatDirection="Horizontal"                          onselectedindexchanged="RadioButtonList1_SelectedIndexChanged">
<asp:ListItem Value="Yes">Yes</asp:ListItem>
<asp:ListItem Value="No" Selected="True">No</asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
<tr id="name2" style="visibility:hidden">
<td>
Other names or aliases?*: 
<asp:TextBox ID="TextBox3" CssClass="textboxhalf" runat="server"></asp:TextBox>
</td>
</tr>
</table>

C#
protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (RadioButtonList1.SelectedValue == "1")
        {
            TextBox3.Visible = true;
        }
        else
        {
            
            TextBox3.Visible = false;
        }
    }

In code behind i able to access this textbox3...so i can make it visible or hide but i cannot access table row id(name2). I want to show/hide whole table row with id name2. Is that possible by only C#?
Posted

1 solution

You missing the the runat="server" attribute.
That will tell ASP.NET to create a server side object for that element. Elements without it will be accessible only from the client...
ASP.NET
<table><tbody><tr id="name2" style="visibility:hidden" runat="server"></tr></tbody></table>
 
Share this answer
 
Comments
Raj Negi 10-Dec-14 3:01am    
yeah you are right...thanks to remind me.
Kornfeld Eliyahu Peter 10-Dec-14 3:13am    
You are welcome!

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