views:

888

answers:

4

Hi!

How can update a input hidden inside an UpdatePanel on an AsyncPostBack?

The user click a button outside the panel. The method associated with click event update the value of the input (it has runat="server" property).

I can't update the value of this input.

I need to store a value to use in the following postback. Maybe I can use session to store this value.

Any advice?

Thank you!

A: 

Because its a postback, you might have to perform a check in the post back event and perform the update. If not, you might have to override an earlier event. See http://msdn.microsoft.com/en-us/library/dct97kc3.aspx

johnofcross
I don't understand you.
VansFannel
A: 

If you are needing to have the update panel (and its contents) updated based on the user clicking on a button which is not in the update panel, add a section to the update panel like the following:

<asp:Button ID="btnOK" runat="server"/> 
<asp:UpdatePanel ID="pnlMyPanel" runat="server">
    <ContentTemplate>
        <!-- Content to get updated -->
    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="btnOK" />
    </Triggers> 
</asp:UpdatePanel>

The triggers section in the above example tells the update panel to update if the button is clicked.

I'm using this.
VansFannel
A: 

You might want to try an <asp:HiddenField> rather than an <input type='hidden' runat='server'>. I think the asp.net version is more post-back aware.

Keltex
No, it doesn't work.
VansFannel
A: 

No way. The only way to update an input is to do a complete post. It's better to use the object Session.

VansFannel