如何在按钮单击事件或另一个Textbox textChanged事件中调用(触发)TextChanged事件 [英] How to call(fire) TextChanged event in button click event or another Textbox textChanged Event
问题描述
大家好,
我有三个TextBox,每个文本框都有TextChanged事件。我的问题是
如何调用第二个文本框在第一个文本框中更改事件已更改事件和Thired textBox更改了事件和按钮单击事件。
my像这样的代码
Hi All,
I have Three TextBoxes and each and every textbox have TextChanged Event. my question is
how to call second textbox Changed event in first textbox changed event and Thired textBox changed event and button click event.
my code like this
protected void txtNotOver3_TextChanged(object sender, EventArgs e)
{
txtAmount3.Text=txtOver3.Text = txtNotOver2.Text;
txtNotOver2_TextChanged(null, null);
lblMsg.Text = "";
}
但我的代码无效..
请帮帮我。
谢谢和问候
but my code is not working..
please help me.
thanks and regards
推荐答案
我修改了我的代码中的一行。
am modify the one line in my code.
protected void txtNotOver3_TextChanged(object sender, EventArgs e)
{
txtAmount3.Text=txtOver3.Text = txtNotOver2.Text;
txtNotOver2_TextChanged(sender, e);
lblMsg.Text = "";
}
感谢和问候
thanks and regards
在aspx页面中的
这样做..
<如果您有任何服务器端处理,则需要
....
in aspx page do this..
if you have any server side processing....
<asp:textbox id="txtNotOver3" runat="server" autopostback="True" ontextchanged="txtNotOver2_TextChanged" >
如果没有服务器端/数据库交互使用javascript ...
if no server side/database interaction use javascript...
<asp:textbox id="txtNotOver3" runat="server" >
<asp:textbox id="txtNotOver2" runat="server" >
page_load event
on page_load event
txtNotOver3.Attributes.Add("onblur","ManipulateValue(this)")
并在aspx页面的javascript中处理它
and handle it in javascript in aspx page
<script language="javascript">
function ManipulateValue(txt)
{
your code
}
</script>
如果有,请告诉我帮助..
let me know if it helps..
为什么不尝试下面给出的例子?
Why don''t you try something like the example given below?
protected void FunctionOne()
{
//Your stuff
}
protected void FunctionTwo()
{
//Your stuff
}
protected void FunctionThree()
{
//Your stuff
}
protected void txtNotOver1_TextChanged(object sender, EventArgs e)
{
FunctionOne();
FunctionTwo();
}
protected void txtNotOver2_TextChanged(object sender, EventArgs e)
{
FunctionTwo();
}
protected void txtNotOver3_TextChanged(object sender, EventArgs e)
{
FunctionThree();
FunctionTwo();
}
protected void Button1_Click(object sender, EventArgs e)
{
FunctionTwo();
}
这篇关于如何在按钮单击事件或另一个Textbox textChanged事件中调用(触发)TextChanged事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!