事件文本已更改为TextBox [英] Event Text Changed of TextBox

查看:82
本文介绍了事件文本已更改为TextBox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有2个文本框,当我在ferst写东西时,seconde会禁用

这是代码




I have 2 textbox i want when i write something in the ferst the seconde will disable
this is the code

<asp:TextBox ID="TextBox2" runat="server" OnTextChanged="TextBox2_TextChanged"></asp:TextBox>

        <asp:TextBox ID="TextBox3" runat="server" Enabled="False"></asp:TextBox>










protected void TextBox2_TextChanged(object sender, EventArgs e)
        {

                if (TextBox2.Text != "")
                {
                    TextBox3.Enabled = false;
                }
                else
                {
                    TextBox3.Enabled = true;
                }
         }





但是当我在textbox2中写东西时,文本框不会禁用plz帮助我



but when i write something in textbox2 the Textbox don't disable plz help me

推荐答案





你需要为TextChanged处理程序执行回发以进行触发,添加值为True的AutoPostBack属性将为您执行此操作。



这样的事情:

Hi,

You'll need to perform a postback for the TextChanged handler to fire, adding the AutoPostBack attribute with a value of True will do this for you.

Something like this:
<asp:TextBox ID="TextBox2" runat="server" OnTextChanged="TextBox2_TextChanged" AutoPostBack="True"></asp:TextBox>





...希望它有所帮助。



... hope it helps.


这篇关于事件文本已更改为TextBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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