Link to home
Start Free TrialLog in
Avatar of dkilby
dkilbyFlag for Canada

asked on

ASP.NET + Content Pane's and Loading User Control

i want to create a page using vb.net where i have 2 panes, once the user logins in, the left pane will hold a list of links (linkbuttons) that when they click on one it will load a user control into the main pane.  The links list pane is also a user control, is this possible?  and if so how would i do it, i tried putting the code to load the control into the main pane but that didn't work.

thanks
Avatar of mmarinov
mmarinov

Hi dkilby,

you have to choose some way of understaning if a user control ( within main pane ) should be visible or not
this you can perform:
1. if your links are HyperLink controls - by sending some querystring parameters
2. if your links are LynkButton controls - give them one event hadler for onclick event and set the CommandName of each control to different values. then within this event hadler you will know which Linkbutton was pressed and which user control within the main pane to show

Regards!
B..M
mmarinov
Avatar of dkilby

ASKER

i have my default.aspx page with 2 panes, left and content.  if the user is not authenticated then in the left pane the login.ascx user control will load. If they are authenticaed the the menu.ascx user control will load.  The menu.ascx control contains link buttons.  I tried loading a different control into the main content pane on default.aspx from the menu.ascx, but i can't get it to work.

        If Request.IsAuthenticated = False Then
            LeftPane.Controls.Add(Page.LoadControl("~/Modules/login.ascx"))
            LeftPane.Visible = True
        Else
            LeftPane.Controls.Add(Page.LoadControl("~/Modules/Menu.ascx"))
            LeftPane.Visible = True
        End If

Menu.ascx

    Private Sub lnk_csrsearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lnk_csrsearch.Click
        ContentPane.Controls.Add(Page.LoadControl("~/Modules/csrsearch.ascx"))
        ContentPane.Visible = True
    End Sub

I get the errror "Name 'ContentPane' is not declared."  
ASKER CERTIFIED SOLUTION
Avatar of YZlat
YZlat
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial