选中单选按钮时如何显示文本框 [英] how to display textbox , when radio button selected

查看:168
本文介绍了选中单选按钮时如何显示文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友们,



我正在使用C#和数据库作为SqlServer 2005在Asp.net项目上工作。



在我的网页上我有Radiobuttonlist,里面有4件物品



4件物品是

1)Airtel 2)IDEA 3) Docomo 4)其他



当我从Radiobuttonlist中选择OTHER时,必须显示一个文本框。所以用户可以在该文本框中输入他喜欢的内容。



请你能帮我解决这个问题,谢谢

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

推荐答案

<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事件处理文本框。





on RadioButtonList1_SelectedIndexChanged Event Handle the textbox.

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

            }
            else
            {
              TextBox1.Visible =false;
            }
        }


最初应该隐藏文本框可见性属性并选择radion按钮事件检查是否选择了第4项,如果是如果为true,则将文本框可见性属性设置为可见。
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.


在DIV元素内添加文本框。在页面加载时隐藏div。在单击复选框列表中注册java脚本。如果复选框选中的值为其他,则使该DIV元素可见。多数民众赞成。
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.


这篇关于选中单选按钮时如何显示文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆