Update panel and hidden fields in a server control

454 views Asked by At

I am creating a custom server control and creating an update panel server-side and a few hidden fields in the server-side, as follows:

UpdatePanel UpdatePanel = new UpdatePanel();
UpdatePanel.ID = "udpReport1";
UpdatePanel.UpdateMode = UpdatePanelUpdateMode.Conditional;
UpdatePanel.ChildrenAsTriggers = true;

Hidden field below:

HiddenField HiddenField = new HiddenField();
HiddenField.ID = "hdnField";
UpdatePanel.ContentTemplateContainer.Controls.Add(HiddenField);

The hidden field values are assigned by JavaScript. Now, when I call __doPostBack() on the update panel using JavaScript, all my hidden fields lose their value as they are reinitialised when rendering my server control. This is a server control so I cannot declare these fields from my .aspx page. I need a way to retain these values when the update panel is posted back. Also, I'm already using __EVENTARGUMENT to store some other values, and require more hidden fields to retain some more values.

Can someone point out how can I retain the hidden field values on posting back the update panel?

Thanks.

1

There are 1 answers

1
Sudhakar Rao On

did you set the update panel visiable status(true or false).