views:

104

answers:

2

Hello!

I'm workin on my first webpart. I use some number of user controls as screens. And I have a trouble here.

First screen contains a list of dynamically created options (hyperlinks). After user made a decision with click, I want to change the screen and pass to the new screen some parameters.

  1. My dicision is to load all controls I need on webpart creation. Controls I don't need right now I make invisible.

        SomeUserControl1 uc1 = (SomeUserControl1)Page.LoadControl("~/_controltemplates/SomeUserControl1.ascx");
        SomeUserControl2 uc2 = (SomeUserControl2)Page.LoadControl("~/_controltemplates/SomeUserControl2.ascx");
        uc2.Visible = false;
    
    
    
    Controls.Add(uc1);
    Controls.Add(uc2);
    
  2. Option in first user control realized as LinkButtons (serverside). OnClik event calls a special method in the webpart class and in this method i change a visibility of my user controls and pass some parameters to usercontrol2.

I don't like this approach. Are there different ways to realize described functionality?

Thanks!

A: 

You need use a ASP.NET Wizard Control, it does what you exactly you want.

Kusek
Thank you for suggestion!
RollingStone
A: 

From a design standpoint what you are doing looks a little bit frightening. You should think about nesting the various user controls into a single user control that you can use as the face of your webpart. Keep the coupling between the various user controls loose and think about implementing the Observer pattern if you need to do things like playing with control visibility.

Repo Man