Wednesday, March 21, 2012

Events are not triggered ?

Hello

How does it come that when I use the click event of an asp:Button control to trigger an asynchronous roundtrip to the server, it works.
When I use the TextChanged event of the asp:TextBox control however, nothing happens...

Here is my example code:

<asp:ScriptManager ID="ScriptManager1" runat="server">

</asp:ScriptManager>

<asp:UpdatePanel ID="myUpdatePanel" runat="server">

<ContentTemplate>

<asp:Label ID="myLabel" runat="server" Text=""></asp:Label>

</ContentTemplate>

<Triggers>

<asp:AsyncPostBackTrigger ControlID="myTextBox" EventName="TextChanged" />

</Triggers>

</asp:UpdatePanel>

<div>

<asp:TextBox runat="server" ID="myTextBox" Text=""></asp:TextBox>

<asp:TextBox runat="server" ID="SecondTextBox" Text="Second"></asp:TextBox>

</div>

<

asp:ScriptManagerID="ScriptManager1"runat="server"></asp:ScriptManager>

<asp:UpdatePanelID="myUpdatePanel"runat="server">
<ContentTemplate>
<asp:LabelID="myLabel"runat="server"Text=""></asp:Label>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTriggerControlID="myTextBox"EventName="TextChanged"/>
</Triggers>
</asp:UpdatePanel><div>
<asp:TextBoxrunat="server"ID="myTextBox"Text=""></asp:TextBox>
<asp:TextBoxrunat="server"ID="SecondTextBox"Text="Second"></asp:TextBox>
</div>I think you'll find it probably needs to trigger a postback to work. Try using AutoPostBack="true" on the textbox in question.

Check out this great post by Luis:

http://forums.asp.net/thread/1532495.aspx

Cheers,

Bogdan


The solution to my problem is as follows

<script type="text/javascript">

$addHandler($get("txtName"), "keyup", functionToExecute);

function functionToExecute(e)
{

}

</script>

No comments:

Post a Comment