如何在用户点击时将一个价值带给另一个价值? [英] how can I get one value to another on user click?
本文介绍了如何在用户点击时将一个价值带给另一个价值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个文本框.
当我按下按钮时,文本框1的文本必须自动显示在textbox2上.
我使用VS 2010,并且在c#中需要此代码.
I have two textboxes.
When I press a button, the text of textbox one must automatically be displayed on textbox2.
I used VS 2010 and I need this code in c#.
推荐答案
使用给定的代码
Use given code
protected void Button1_Click(object sender, EventArgs e)
{
TextBox2.Text = TextBox1.Text;
}
:-D
:-D
使用JQuery玩得开心:
Have some fun with JQuery:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js?ver=2.9.2'></script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txt1" runat="server" CssClass="one"></asp:TextBox>
<asp:TextBox ID="txt2" runat="server" CssClass="two"></asp:TextBox>
<br />
<asp:Button ID=btnCopy runat=server Text="Copy" CssClass=btn OnClientClick="return false;" />
</div>
</form>
<script type="text/javascript">
(document).ready(function(){
(document).ready(function () {
这篇关于如何在用户点击时将一个价值带给另一个价值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文