I'm having trouble reading a server-side set value from an input, after an UpdatePanel partial postback
This is the simplest example I can use to reproduce the issue:
<asp:ScriptManager runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Panel ID="pnlSrc" runat="server">
<asp:TextBox ID="txtInput" runat="server" AutoPostBack="true"
OnTextChanged="txtInput_TextChanged"></asp:TextBox>
</asp:Panel>
<asp:Panel ID="pnlDst" runat="server">
<asp:TextBox ID="txtOutput" runat="server" />
<a id="lnkTest" href="#" onclick="pageLoad();">check txtOutput</a>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
<script type="text/javascript">
var txtOutput = $('#<%=txtOutput.ClientID%>');
function pageLoad() {
var exe = $(txtOutput).text();
alert(exe);
}
</script>
Server side, I'm just putting txtInput text reversed into txtOutput:
protected void txtInput_TextChanged(object sender, EventArgs e)
{
var txt = string.Empty;
for (int i = txtInput.Text.Length - 1; i >= 0; i--)
{
txt += txtInput.Text[i];
}
txtOutput.Text = txt;
}
Client side, pageLoad() is executed after every partial postback, but txtOutput value is never updated: it's always the same of the first load (empty, in this case)
I tried also with getInstance().add_endRequest but no success
I would expect that 'exe' contains the actual value of txtOutput.Text, set server side, but it's not so
Clicking lnkTest, the same function is invoked with the expected result
Sorry if I'm doing something wrong, this is my first post
Thank you