将相同的数据从一个文本框传输到另一个文本框 [英] Transferring same Data from One TextBox To Another TextBox

查看:71
本文介绍了将相同的数据从一个文本框传输到另一个文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我有两个TextBoxes.当我填充一个TextBox时,然后单击Checkbox,TextBox的数据将填充到第二个TextBox中.如何实现.


谢谢您,
Amit Mehan

Hello All,
I have Two TextBoxes.when I fill one TextBox Then On Clicking Checkbox,the data of TextBox will be filled into second TextBox.How It can be done.


Thanks With Regards,
Amit Mehan

推荐答案

那很容易.

如果您有两个文本框(textBox1和textBox2)和一个CheckBox(checkBox1),则只需将以下行添加到checkBox1.CheckedChanged EventHandler

Thats easy.

If you have two text boxes (textBox1 and textBox2) and a CheckBox (checkBox1) you just need to add the following line to the checkBox1.CheckedChanged EventHandler

textBox2.Text = textBox1.Text


在CheckBox Click事件中:
In the CheckBox Click event:
textBox2.Text = textBox1.Text;


如果您想在客户端进行操作

1.在复选框(javascript)中添加onclick事件处理程序
点击
If you want to do in client side then

1. Add onclick event handler in checkbox (javascript)
function clicked(objCheckBox)
        {
            document.getElementById("<% =TextBox2.ClientID %>").value = document.getElementById("<% =TextBox1.ClientID %>").value;
        }



2.将onclick事件处理程序添加到复选框



2. Add onclick event handler to checkbox

CheckBox1.Attributes.Add("onclick", "clicked(this)");



如果要在服务器端进行操作,只需添加CheckChanged事件



If you want to do in server side then simply add CheckChanged event

<asp:CheckBox ID="CheckBox1" runat="server"
        oncheckedchanged="CheckBox1_CheckedChanged" />



在aspx.cs页面中



And in aspx.cs page

protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
    {
        TextBox2.Text = TextBox1.Text;
    }


这篇关于将相同的数据从一个文本框传输到另一个文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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