I have a user control thats dynamically loaded when someone click a linkbutton. In order to maintain the viewstate, I declare a Viewstate("ID") and hold a value. If the page is posted back, I do If..end if statement to look for the Viewstate("ID"), if found.
I send it to the method to load the user control. Now if I click on another linkbutton in the main aspx page, it loads the user control again with the new value set ot the viewstate("ID"). But in fact it loads another user control and I now have 2 user controls
loaded even though only 1 is showing. I can tell because my user control has a linkbutton and when its loaded the 1st time, it has a value of clt4_Submit and when I select another button in the main page, the user control is reloaded and the buttoin within
it is now clt5_Submit, if I click the linkbutton in the user control, the user control is reloaded from viewstate, but the linkbutton inside the user control is reset correctly back to clt4_Submit. What can I do to prevent the user control from loading twice,
I have my placeholder cleared on the method that loads it.
vpaul
Member
135 Points
27 Posts
Preventing a dynamic user control from loading twice
Aug 22, 2003 03:33 PM|LINK