OnTextChanged event is not firing

I have a TextBox inside my .Aspx page:

<ajax:UpdatePanel ID="UpdatePanel2" runat="server">
    <ContentTemplate>
        <asp:TextBox ID="txtCity" AutoPostBack="true" OnTextChanged="txtCity_TextChanged"
            Width="90%" runat="server" ></asp:TextBox>
    </ContentTemplate>
</ajax:UpdatePanel>

Code behind:

protected void txtCity_TextChanged(object sender, EventArgs e)
{
    lblMessage.Text = "you have typed:" + txtCity.Text;
}

And for lblMessage [on the same .Aspx page]:

<ajax:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
        <asp:Label ID="lblMessage" runat="server" Text="" ></asp:Label>
    </ContentTemplate>
</ajax:UpdatePanel>

But when I am typing in the TextBox. lblMessage is not updating.

How to rectify this?

5
задан 5377037 4 October 2017 в 12:01
поделиться