G
Gopal Krish
I'm have coded a simple menu (using link buttons as menu items) in a
user control to be reused across many ASPX pages.
In the page_load method I dynamically create the link buttons as
follows
LinkButton myLB = new LinkButton();
.........
.........
I put the above code inside a for loop so that many link buttons will
be created based on the number of elements in the array (and hence
forming my simple menu link that goes on top of each page).
The key point is that I have put the above mentioned logic in the
(!IsPostBack) block. The first time the page loads, eveything is fine.
But after a postback my screen looks empty.
If I remove the (!IsPostBack) block then everything works fine
(because all the code is executed whether its postback or not), which
I think is a perfromance issues and would like the state to be
preserved by asp.net.
Questions:
1. Just wondering whether ASP.NET will maintain viewstate when using
dynamically created controls in a user control?
2. If I implement the same functionality using custom controls
(instead of usr controls) then will viewstate will be preserved
automatically?
Thanks for your time....
user control to be reused across many ASPX pages.
In the page_load method I dynamically create the link buttons as
follows
LinkButton myLB = new LinkButton();
.........
.........
I put the above code inside a for loop so that many link buttons will
be created based on the number of elements in the array (and hence
forming my simple menu link that goes on top of each page).
The key point is that I have put the above mentioned logic in the
(!IsPostBack) block. The first time the page loads, eveything is fine.
But after a postback my screen looks empty.
If I remove the (!IsPostBack) block then everything works fine
(because all the code is executed whether its postback or not), which
I think is a perfromance issues and would like the state to be
preserved by asp.net.
Questions:
1. Just wondering whether ASP.NET will maintain viewstate when using
dynamically created controls in a user control?
2. If I implement the same functionality using custom controls
(instead of usr controls) then will viewstate will be preserved
automatically?
Thanks for your time....