Last post Aug 04, 2008 12:43 PM by Peter Bucher
Jul 30, 2008 06:03 AM|intelligents|LINK
I am having a user control. I am putting that control on some page. And also i am adding multiple isntances of the same control every time i am clicking on Add new Button.
I have a few textboxes in my user control and enableviewstate property of these textboxes is true. But after adding new instance of user control, controls which are already added r losing thie values in text boxes.
Following is the code:
this is the code of Page_Load of parent page which is hostng the user control:
CQControl.HeadingText = ((
Jul 30, 2008 07:26 AM|MelvynHarbour|LINK
The problem is that you are creating new instances of the controls on each page request, whether it is a PostBack or not. As such ASP.NET can't tie the values together. Effectively they aren't 'the same' controls. I think your solution is to explore using
something like this
Aug 04, 2008 12:43 PM|Peter Bucher|LINK
I think the problem is that you are reusing instances of your Controls throught server roundtrips.
If you instantiiate the Controls per Request and also wheter its Postback or not, it should run "better".
This is a solution, but i don`t like it.
Its not about handle scenarios in a stateless web environment and it builds heavy on postbacks.