要在文本框中显示的数据 [英] Data to be displayed in Textbox

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

问题描述

你好,

我有两个分别名为box1和box2 respt的文本框... box1有一个特定的值,例如100.单击box1时,需要使该值显示在box2上.
我尝试在box1上进行text_changed事件,但无法完成,因为我们应该在box1中输入一些值并输入click.单击或单击box1.

Hello,

I have two textboxes named box1 and box2 respt... box1 has a particular value say 100. I need to get that value to be displayed on box2 when I single click (mouse) on the box1.

I tried for text_changed event on box1 but it is not possible as we should enter some value in box1 and enter click.. But what i need is without writing anything in the box1, I need to get the data displayed from box1 to box2 on enter click or mouse click of box1.

推荐答案


您可以在文本框onblur事件中执行此操作.
javascript中的功能
函数复制(Box 1,Box2)
{

//var box1 = document.getElementById(Box1).value;
//var box2 = document.getElementById(Box2).value;
//box2.value = box1;
//------------------------------------------------ ---
var box1 = document.getElementById(Box1);
var box2 = document.getElementById(Box2);
box2.value = box1.value

}

在.cs页面中
在pageload()下,您可以将属性添加为
box1.Attributes.Add("onblur","copy(""+ box1.ClientID +"''," + box2.ClientID +'')");

每当焦点从文本框"box1"发出时,都会触发此事件

you can do that in textbox onblur event .
function in javascript
function copy(Box 1,Box2)
{

// var box1= document.getElementById(Box1).value;
// var box2 = document.getElementById(Box2).value;
// box2.value=box1;
//---------------------------------------------------
var box1= document.getElementById(Box1);
var box2 = document.getElementById(Box2);
box2.value=box1.value

}

in .cs page
under pageload() you can add attribute as
box1.Attributes.Add("onblur","copy(''"+box1.ClientID+"'',''"+box2.ClientID+"'')");

this event will fire every time focus comes out of textbox ''box1''


这篇关于要在文本框中显示的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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