Losing user control

D

David Colliver

Hi all,

I am setting up a tab strip in an aspx page. I am using
link buttons to switch between the tabs (at the moment,
it is just link buttons, no tabs...)

Under each link button, I intend to add a usercontrol. I
have written one so far. I am adding the UC dynamically
in the button click event of my tab strip.

I am also setting properties and calling a method in the
UC.

My UC is set up like a wizard using back and next buttons
to go backwards and forwards.

However, on the first page of the UC, if I click next, I
lose the control altogethor.

I am assuming that I probably need to hold the UC in the
viewstate somehow, but I don't know how to do that.

Also, if I switch tabs and load a different UC, will I
lose what has been entered in the UC that is no longer
being viewed?

Here is my code...
The ApplicationOverviewLinkButton is the one that will be
one of my tab buttons.


private void
ApplicationOverviewLinkButton_Click(object sender,
System.EventArgs e)
{
UserControl MyRegistration =
(UserControl)LoadControl
("../CMSUserControls/nqt/registration.ascx");

RegistrationDetailPanel.Controls.Add
(MyRegistration);


((MyCMSApp.CMSUserControls.nqt.registration)
MyRegistration).LoggedInUser = "LoggedInUserName";

((MyCMSApp.CMSUserControls.nqt.registration)
MyRegistration).FillData();
RegistrationDetailPanel.Visible =
true;
MyRegistration.Visible = true;
}


Thanks for any help.

Regards,
Dave Colliver.
http://www.IlfracombeFOCUS.com
~~
http://www,FOCUSPortals.com - Portal franchises available
 
D

David Colliver

Hi Brock,

Magic. :)

I am assuming though that as the control is not held
during postback (or is it?) that I need to save the
content (forms on each page) at every single postback.

I noted you answered my question on the security group. I
need to supply more info as I don't think your current
reply really fits.

Best regards,
Dave Colliver.
http://www.CardiffFOCUS.com
 
D

David Colliver

Hi Brock,

I just discovered a slight flaw...

Say I have 3 tabs. The first tab has a usercontrol that
in itself has more than 1 page. The second and third tab
have a simple single page usercontrol.

Now, if I go to the first tab, I can next and previous
the pages in the first user control OK.

If I switch to the second (or 3rd) tab, these switch OK.

If I now go back to the first one, this swiches OK, but
if I next the page on the first tab, then I get the
content of the 2nd/3rd tab also displayed.

This is incremental. If I switch to the 2nd tab, then
back to first, then page in the first, the 2nd tabs
usercontrol is added to the list, so for each tab switch,
I get more and more content on the page.

I think I need to somehow drop the items in the
DynamicContent arraylist, but now sure where I should do
this.

Cheers.
Dave Colliver.
http://www.GreatYarmouthFOCUS.com
 
B

Brock Allen

I am assuming though that as the control is not held during postback
(or is it?) that I need to save the content (forms on each page) at
every single postback.

As long as you recreate the controls like I showed in the sample from the
link, they do hold their own state. You should not have to manually reset
their state. That would defeat the whole purpose of using server controls.
 
B

Brock Allen

If I now go back to the first one, this swiches OK, but if I next the
page on the first tab, then I get the content of the 2nd/3rd tab also
displayed.

This sounds like a flaw in how the tab controls tracks which tab it should
be on.
 

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

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top