Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Friends,

am working on Asp.net Project using C# and Database as SqlServer 2005.

On my webpage i have Radiobuttonlist with 4 items in it

The 4 items are
1)Airtel 2)IDEA 3)Docomo 4)Other

When i select OTHER from Radiobuttonlist a textbox must be displayed. so user can enter as he like in that textbox.

Please can you help me how to do this, thanks
Posted

XML
<asp:Radiobuttonlist id="RadioButtonList1" runat="server" repeatdirection="Horizontal" autopostback="True" onselectedindexchanged="RadioButtonList1_SelectedIndexChanged" xmlns:asp="#unknown">
             <asp:listitem enabled="true" value="Airtel">Airtel</asp:listitem>
             <asp:listitem enabled="true" value="IDEA">IDEA</asp:listitem>
             <asp:listitem enabled="true" value="Docomo">Docomo</asp:listitem>
             <asp:listitem enabled="true" value="Other">Other</asp:listitem></asp:Radiobuttonlist>


on RadioButtonList1_SelectedIndexChanged Event Handle the textbox.

C#
protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (string.Equals(RadioButtonList1.SelectedValue,"Other"))
            {
               TextBox1.Visible = true;

            }
            else
            {
              TextBox1.Visible =false;
            }
        }
 
Share this answer
 
v5
Comments
Joezer BH 6-May-13 7:57am    
5ed!
Thanks7872 6-May-13 7:58am    
Thanks Edo.
Ubaid ur Rahman IT 7-May-13 1:29am    
sorry this is not working & it shows error near string.equals like this.......

An object reference is required for the non-static field, method, or property 'object.Equals(object)'

Please help

Thanks.
Thanks7872 7-May-13 1:35am    
Refer to updated answer replace the selectedindexchanged event with updated code.You should accept the answer if it helps you.
initially the textbox visibility property should be hidden and in radion button selected event check whether 4th item selected ,if it is true then set textbox visibility property to visible.
 
Share this answer
 
Add your text box inside of a DIV element. Hide the div on page load. Register a java script on click for checkbox list. If checkbox selected value is Other means, make visible that DIV element. Thats all.
 
Share this answer
 

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