Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Storing a pointer to a user control

I have a user control that I want to reference at postback programatically.

In order to do so, I'll need to persist information in viewstate.

I have 2 options:

  1. Store the control ID in viewstate and find the control on the page each time
  2. Store the control in viewstate i.e. WebControl and do not need to find each time

Is there any downside to going with option 2 over 1?

like image 410
dotnetnoob Avatar asked Aug 26 '26 22:08

dotnetnoob


1 Answers

You cannot store any 'object' in ViewState, as it is created every time during Load phase, and dies during Unload. Control cannot be serialized. Go with the option 1.

like image 98
nothrow Avatar answered Aug 28 '26 11:08

nothrow



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!