在ASP.NET,C#中选中复选框时显示文本框 [英] Display TextBox when Checkbox Checked in ASP.NET,C#

查看:115
本文介绍了在ASP.NET,C#中选中复选框时显示文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,

我正在研究调查项目. (ASP.Net,C#,SQLSERVER 2005)

我在网络表单上有15个带有是"或否"单选按钮的问题.单击提交按钮后,其工作正常并存储在数据库中.

现在,除了那个单选按钮,我还有一个复选框和TEXTBOX.

当我选中(勾号)复选框时,应显示该文本框,并且用户应在文本框中输入评论,然后他应提交评论.


注意:如果用户选中了CHECKBOX ....,则TEXTBOX必须显示在该复选框旁边....如果不显示,则为
.
请问有人可以为此提供解决方案吗?

非常感谢.

Dear all,

I am working on SURVEY PROJECT. (ASP.Net, C#, SQLSERVER 2005)

I have 15 Questions with Yes or NO Radio buttons on webform. its working fine and storing in database after submit button click.

Now , BESIDE that radio buttons I have a check box and TEXTBOX.

When i check(Tick) the Checkbox, The textbox should be displayed and User should enter the comments in the textbox and he should the submit it.


Note : if the user checks the CHECKBOX....the TEXTBOX must be displayed beside that checkbox....if not dont display.

Please can anybody can give the solution for this ?

Thank you very Much.

推荐答案

您尝试了吗?尝试使用javascript来满足您的要求.您可以在
Did you try something? Try using the javascript for your requirement. You can see millions of examples in Google[^]


<script language="javascript" type="text/javascript">
function forRentClicked(sender)
{
            var tb1 = document.getElementById('<%= TextBox1.ClientID %>');
            tb1.style.display = sender.checked?'inline':'none';
}
</script>


<asp:checkbox id="CheckBox1" runat="server" onclick="forRentClicked(this)" checked="true" />
<asp:label id="Label1" runat="server" text="Rental rate per week:"></asp:label>
<asp:textbox id="TextBox1" runat="server" ></asp:textbox>




http://forums.asp.net/t/1632866.aspx/1 [ ^ ]




http://forums.asp.net/t/1632866.aspx/1[^]


使用此i:

使复选框自动回发属性为True.和文本框visible = false


然后双击复选框:
Use this i:

Make Checkbox Autopostback Property True. and textbox visible=false


Then Double click on Checkbox :
if(chk.checked)
{
  textbox.visible=true;
}
else
{
  textbox.visible=false;
}



如果对您没有帮助,请将其发布.



if not help to you , please post it.


这篇关于在ASP.NET,C#中选中复选框时显示文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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