Sharepoint Web Part OnPreRender PostBack Dynamic TextBoxes Not Accessible In Button Handler

Posted by Matt on Stack Overflow See other posts from Stack Overflow or by Matt
Published on 2010-05-12T21:17:40Z Indexed on 2010/05/12 21:24 UTC
Read the original article Hit count: 662

Filed under:
|
|
|

I have a custom webpart which extends System.Web.UI.WebControls.WebPart and implements an EditorPart.

I have all the static controls being added in the overridden CreateChildControls method as I know this makes them persistent across PostBacks.

However, I have some TextBoxes being added in the overridden OnPreRender method because the actual TextBoxes that I add depend upon the data returned from a Web Service which I am calling in OnPreRender. The Web Service has to be called in OnPreRender because I need some of the Property values that are set in the EditorPart. If I build this logic into the CreateChildControls method, obviously the data is not available on first PostBack after an edit is applied because the PostBack events are restored after CreateChildControls. This means the page has to be posted twice before the data is refreshed and that is just cludgy.

How can make these TextBoxes along with their entered text values persistent across PostBacks so that I can access them in the button handler?

Thanks for any help, Matt

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET