0

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?

4

1 回答 1

1

您无法在Init事件中获取 TextBox 的更新值。此事件在页面生命周期中执行得太早,在页面控件设置为发布值之前。为什么不Button1点击一下呢?

这篇MSDN 文章可能会帮助你了解 asp.net 页面的生命周期

于 2012-06-07T16:52:47.790 回答