Repost : Viewstate being maintained second time around

J

John

Hi all,

I have a problem with viewstate being maintained. I use LoadControl to load
a user control and the data is sent down to the client correctly. However,
when I change some data and post it, the viewstate does not seem to load for
the user control upon sending it back down to the client. If I change the
data again, then the viewstate DOES seem to be maintained.

What gives?

Regards
 
H

HrtgSkr

John -
I had quite a bit of trouble getting a usercontrol to work when the
usercontrol included webcontrols that I wanted to interact with the
parent.
The best way I found to work is to drag the usercontrol onto the
parent, then toggle the visible property, rather than using
LoadControl.
My web page is in GridLayout, so I programmatically move it to
position when it's changed to visible = true.
I also found that ViewState wasn't working. I found an usercontrol
example that showed removing the OnInit() function in the usercontrol
and replacing it with
public void Page_Init(object sender, EventArgs e)
{
InitializeComponent();
}
** I'm not sure why the example used this method. It seems like you
could just remove the base.OnInit(e) for the Designer generated code,
but I didn't try that.

Then, in the parent, add

this.Init += new System.EventHandler(this.ctlAddNewRule.Page_Init);
(** Mine is in C#, I'm not sure how to do it in VB)

I have this usercontrol on several pages, and it is working
consistently.

Dawn.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top