What do you do when you can't use ViewState?

后端 未结 7 1812
长发绾君心
长发绾君心 2021-02-09 06:43

I have a rather complex page that dynamically builds user controls inside of a repeater. This repeater must be bound during the Init page event before ViewState is

7条回答
  •  庸人自扰
    2021-02-09 07:22

    1) there's probably a way to get it to work... you just have to make sure to add your controls to the tree at the right moment. Too soon and you don't get ViewState. Too late and you don't get ViewState.

    2) If you can't figure it out, maybe you can turn off viewstate for the hole page and then rely only on querystring for state changes? Any link that was previously a postback would be a link to another URL (or a postback-redirect).

    This can really reduce the weight of the page and make it easier to avoid issues with ViewState.

提交回复
热议问题