Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1254
  • Last Modified:

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
0
dkilby
Asked:
dkilby
1 Solution
 
mmarinovCommented:
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
0
 
dkilbyAuthor Commented:
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."  
0
 
YZlatCommented:
Private Sub lnk_csrsearch_Click does not recognize ContentPane

try this:

 Private Sub lnk_csrsearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lnk_csrsearch.Click
       
dim cp as Control
cp=Page.FindControl("ContentPane")

if not cp is nothing then
cp.Controls.Add(Page.LoadControl("~/Modules/csrsearch.ascx"))
        cp.Visible = True

end if
    End Sub
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now