开发者

TextBox.TextChanged event not firing on IE7

In my web form I have a Textbox control. The TextChanged event of the Textbox is not triggering. AutoPostBack is set to true

What could be the reason for this? Here is the code:

protected void Textr_TextChanged(object sender, System.EventArgs e)
{

}

<asp:TextBox ID="Textr" TabIndex="10" Style="z-开发者_如何学运维index: 117; left: 500px;
                            position: absolute; top: 158px" runat="server" Height="22px" Width="180px" MaxLength="50"
                            AutoPostBack="True"   CausesValidation="true"   OnTextChanged="Textr_TextChanged" 
                          ></asp:TextBox>


Are there any validation controls on the form along with this textbox? I see you have causesvalidation explicitly set to true (which I believe is the default state). Try removing that and see if it fires. If the postback is hung up on a validation control, your event handler will not fire.

My two cents.


I had the problem just after adding a standard HTML Input control somewhere else in the document. After this, the TextBox1.TextChanged stopped working.

My solution was to put the textbox into a span with an onclick event ensuring a postback by means of an invisible button like this:

=========

Original:

{asp:TextBox ID="TextBox1" runat="server" /}

=========

Solution:

{span onclick="document.getElementById('btn_ToForcePostback').click();"}

{asp:TextBox ID="TextBox1" runat="server" /}

{/span}

{asp:Button ID="btn_ToForcePostback" runat="server" text="" style="width:0px; height:0px"/}


(The { and } should be changed to "smaller than" and "larger than" character)


Is it working in rest browsers? Don't forget that this event is fired then control is loosing focus. :) Try to click outside of textbox after inputing.


it may be messed up by some javascript you are using on the same page, or else you can make sure yourself if it is IE7 problem or not by making a sample for this. Very high level it looks like sonething related to javascript mess up.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜