Asp.Net文本框TextChanged事件未触发 [英] Asp.Net textbox TextChanged event is not firing

查看:323
本文介绍了Asp.Net文本框TextChanged事件未触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Asp.Net文本框TextChanged事件未触发

解决方案

使用此...

 <   asp:TextBox     ID   =  TextBox1    runat   = 服务器    

onkeypress = document.getElementById('Label1')。innerHTML = this.value; / >
< asp:标签 ID = Label1 runat = 服务器 文字 = / >



如果有帮助,请接受解决方案。


您可以将 AutoPostBack 属性设置为 True ,如下所示:

 AutoPostBack =True





如果将文本框放在AJAX的更新面板中,将会更好地工作=)



在你的HTML代码中:

 <  < span class =code-leadattribute> body  >  
< 表格 id = form1 runat = server 方法 = 发布 autocomplete = off >
< div >
< asp:TextBox ID = TextBox1 runat = server < span class =code-attribute> AutoPostBack = True

ontextchanged = TextBox1_TextChanged >
< / div >

< asp:Label ID = Label1 runat = server 文字 = 标签 >
< asp:按钮 ID = Button1 runat = server T ext = 按钮 / >
< / form >

< / body >





希望它有所帮助。


TextChanged:当文本框的内容在发布到服务器的帖子之间发生变化时发生。 AutoPostBack:使用AutoPostBack属性指定当TextBox控件失去焦点时是否会自动回发到服务器。在TextBox控件中按ENTER或TAB键是更改焦点的最常用方法。

Asp.Net textbox TextChanged event is not firing

解决方案

use this...

<asp:TextBox ID="TextBox1" runat="server" 

            onkeypress="document.getElementById('Label1').innerHTML=this.value;" />
             <asp:Label ID="Label1" runat="server" Text="" />


Pls Accept solution if it help.


You can set the AutoPostBack property to True just like this:

AutoPostBack="True"



Will going to work better if you put the textbox inside an updatepanel from AJAX =)

In your html code:

<body>
    <form id="form1"  runat="server" method="post" autocomplete="off">
    <div>
        <asp:TextBox ID="TextBox1" runat="server" AutoPostBack="True" 

            ontextchanged="TextBox1_TextChanged">
    </div>

    <asp:Label ID="Label1" runat="server" Text="Label">
    <asp:Button ID="Button1" runat="server" Text="Button" />
    </form>
    
</body>



Hope it helps.


TextChanged: "Occurs when the content of the text box changes between posts to the server." AutoPostBack: "Use the AutoPostBack property to specify whether an automatic postback to the server will occur when the TextBox control loses focus. Pressing the ENTER or the TAB key while in the TextBox control is the most common way to change focus."


这篇关于Asp.Net文本框TextChanged事件未触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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