R – User controls as “screens” in a webpart

sharepointuser-controlsweb-parts

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!

Best Answer

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

Related Topic