I’m using an UpdatePanel to asynchronously update a control on my ASP.NET page. During the postback, I’d like to get the value of a TextBox control. The value I get, however, is always the original text value of the TextBox, not the text the user has inputted. How can I get the updated value of the TextBox server-side on a postback?
Thanks in advance for any advice you have to offer.
Here’s the code:
<asp:UpdatePanel ID="GridUpdatePanel" runat="server">
<ContentTemplate>
<asp:GridView ID="AdminGridView" runat="server"
onrowcreated="AdminGridView_RowCreated" AutoGenerateColumns="False"
RowStyle-HorizontalAlign="Center" CssClass="Grid" Font-Size="100%"
BorderColor="Black" oninit="AdminGridView_Init">
</asp:GridView>
<asp:TextBox ID="SortLabel" runat="server" Text="Recipients"></asp:TextBox>
<asp:TextBox ID="DirectionLabel" Text="DESC" runat="server"></asp:TextBox>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1" />
</Triggers>
</asp:UpdatePanel>
–EDIT–
I should add that I’m attempted to retrieve the value of the TextBox in the _Init() Event in the GridView – maybe there’s a better place to retrieve the value of the TextBox?
You can’t get the updated value of your TextBox on
Initevent. This event is executed too early on the page life cycle, before page controls are set with posted values. Why don’t you do it onButton1click?This MSDN article may help you to understand the asp.net page life cycle