想要在点击事件后在文本框中显示值 [英] Want to show value in a text box after click event

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

问题描述

我有两个文本框.

我将计算两个文本框输入的值,然后当我单击第三个文本框时,计算出的值将显示在第三个文本框中.

谁能告诉我该怎么做?

您只能为我提供有关该单击事件的解决方案.

I have two textboxes.

I will calculate the values of two text box inputs then when I click on 3rd text box then the calculated value will be shown on the 3rd text box.

Can anyone please tell me how to do that?

You can only give me solution about that click event.

推荐答案

您需要使用Js onFocus Event.

假设有三个名为的文本框,

TextBox1,TextBox2,TextBox3

然后在TextBox3 Like上编写onFocus事件.

You need to use Js onFocus Event.

Suppose there are three textbox named,

TextBox1,TextBox2,TextBox3

Then write onFocus Event on TextBox3 Like.

<asp:textbox id="TextBox3" runat="Server" onfocus="javascript:focused(this)" xmlns:asp="#unknown" />





function focused(txt3)
{
var result = document.getElementById("TextBox1").value * document.getElementById("TextBox2").value;
            txt3.value = result;

}



[其他答案]
您可以使用 [



[Additional answer]
You could use THIS[^]
[/additional answer] to count date difference.

and your''e done.

Please vote and Accept Answer if it Helped.


使用输入文本框的事件..

使用以下代码

use the enter event of the textbox ..

use the below code

<pre lang="cs">private void textBox3_Enter(object sender, EventArgs e)
       {
           textBox3.Text = Convert.ToString (Convert.ToInt32(textBox1.Text) + Convert.ToInt32(textBox2.Text));
       }



在模糊的情况下进行操作,就像拖动按钮并在按钮上单击以编写您的代码:


textBox3.Text = Convert.ToString(Convert.ToInt32(textBox1.Text)+ Convert.ToInt32(textBox2.Text));


页面的onload事件写这个

受保护的void Page_Load(对象发送者,EventArgs e)
{
Button1.Visible = false;
字符串处理程序= ClientScript.GetPostBackEventReference(this.Button1,");
TextBox2.Attributes.Add("onblur",处理程序);
}
do it on blur like it drag a button and on button click write ur code:


textBox3.Text = Convert.ToString (Convert.ToInt32(textBox1.Text) + Convert.ToInt32(textBox2.Text));

and
onload event of page write this

protected void Page_Load(object sender, EventArgs e)
{
Button1.Visible = false;
string handler = ClientScript.GetPostBackEventReference(this.Button1, "");
TextBox2.Attributes.Add("onblur", handler);
}


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

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