"news.microsoft.com" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello,
>
> I am trying to add an asp.net user control dynamically with the postback
> capability.
>
> Adding a user control seems straightfroward but making postback work is a
> problem. When I say postback, I mean postback handled inside the
> usercontrol.
> e.g. let's say your user control has a text and a button. You save the
> text property in viewstate varible so that it is preserved during
> postback. You assign the new property value from textbox to viewstate
> variable after postback.
>
> Problem comes when controls are created dynamically.
>
> Any help will be appreciated to make this work.
Mark has hit this on the head. In order to work with viewstate, you have to
have the control on the page prior to when viewstate is applied back, which
means before the Load event. Take a look at the page lifecycle events and
you will understand why adding the control on load completely messes up your
system.
--
Peace and Grace,
Greg
Twitter: @gbworld
Blog:
http://gregorybeamer.spaces.live.com
************************************************
| Think outside the box! |
************************************************