Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Call Page function from Child Control

Status
Not open for further replies.

mwa

Programmer
Jul 12, 2002
507
US
I have a .aspx page that has multiple User Controls. There is a sub on the page that is called to show/hide the correct UC:
Code:
    Public Sub ShowModules(ByVal uc As Integer)
        Select Case uc
            Case 1
                WebUserControl11.Visible = True
                WebUserControl21.Visible = False
                WebUserControl31.Visible = False

            Case 2
                WebUserControl11.Visible = False
                WebUserControl21.Visible = True
                WebUserControl31.Visible = False
            Case 3
                WebUserControl11.Visible = False
                WebUserControl21.Visible = False
                WebUserControl31.Visible = True
        End Select
    End Sub

On pageload, the sub is called with ShowModules(1) and UC1 is displayed. On UC1, there is a button. For the OnClick of that button, I would like it to call the Parent's sub with ShowModules(2). Is this possible? How? Or, is there a better way to do it?

Thanks,

mwa
<><
 
User controls should be independent of each other. In your case you are tying them together through the page, therefore there functionality is tied together. Each user control should be something that is reusable and independent. In your case it is not. YOu should look again at what you are trying to accomplish and redesign the page.

If you just want to show/hide objects based on some critera of the page, then I would use the MultiView control.
 
Sorry, I'm using ASP.net 1.1... No MultiView control.

So, how then would I best set up a page that has 3 Steps? After completing Step 1 it should automatically navigate to Step 2. Once the user is at Step 2, he can choose to complete Step 2, or Navigate to Step 3. Then he can navigate back and forth through the 3 steps. The function controls that now is called by page level linkbuttons. It's that auto-navigate upon an action on Step 1 to Step 2 that's got me.

Right now, I have it set as I described with 1 page, and 3 user controls representing each of the steps. How would I change this to accommodate my needs?

mwa
<><
 
You might want to upgrade to 2.0. There is a wizard control which is exactly what you need.

For now, you can create 3 pages, 1 for each step, and store the values in session so the user can go back and forth between steps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top