deon001
asked on
Opening UserControl from menu ASP.Net 2005
Hi Experts
I’m new to ASP 2.0 .Net 2005 and have setup a default.aspx page with a menu control.
<Items>
<asp:MenuItem Text="MenuOption1" Value="AAA">
<asp:MenuItem Text="Option A1" Value="A1"></asp:MenuItem>
<asp:MenuItem Text="Option A2" Value="A2"></asp:MenuItem>
</Items>
When I click on my menu Items(“Option A1”) I want to load a WebUserControl.ascx into a table on the default.aspx page.
How do I then open(call) the user control to open-up inside the table on the default.aspx page? This should be something very simple to do…
Thanks for the help!
Deon
I’m new to ASP 2.0 .Net 2005 and have setup a default.aspx page with a menu control.
<Items>
<asp:MenuItem Text="MenuOption1" Value="AAA">
<asp:MenuItem Text="Option A1" Value="A1"></asp:MenuItem>
<asp:MenuItem Text="Option A2" Value="A2"></asp:MenuItem>
</Items>
When I click on my menu Items(“Option A1”) I want to load a WebUserControl.ascx into a table on the default.aspx page.
How do I then open(call) the user control to open-up inside the table on the default.aspx page? This should be something very simple to do…
Thanks for the help!
Deon
ASKER
Hi Sammy, thanks for the quick response.
I have done this previously in .NET 2003 VB and am now moving to ASP C# 2005, and am battling to get the same ting going.
How I did it in VB:
Protected WithEvents ContentPane As System.Web.UI.HtmlControls .HtmlTable Cell
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
InitializeComponent()
Dim ContentPage As String = ""
ContentPage = Request.QueryString("Conte ntPage")
If ContentPage = "" Then
ContentPane.Controls.Add(P age.LoadCo ntrol("~/L aborContro l/Welcome. ascx"))
Else
ContentPane.Controls.Add(P age.LoadCo ntrol("~/" & ContentPage))
End If
ContentPane.Visible = True
End Sub
Then I just opened my controls like this:
<div class="clsMenuItem">
<A href="Home.aspx?contentpag e=Folder1/ MyWebUserC ontrol.asc x">Option1 </A>
Im very new at this so thanks for the help and patients
Deon
I have done this previously in .NET 2003 VB and am now moving to ASP C# 2005, and am battling to get the same ting going.
How I did it in VB:
Protected WithEvents ContentPane As System.Web.UI.HtmlControls
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
InitializeComponent()
Dim ContentPage As String = ""
ContentPage = Request.QueryString("Conte
If ContentPage = "" Then
ContentPane.Controls.Add(P
Else
ContentPane.Controls.Add(P
End If
ContentPane.Visible = True
End Sub
Then I just opened my controls like this:
<div class="clsMenuItem">
<A href="Home.aspx?contentpag
Im very new at this so thanks for the help and patients
Deon
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
this is a great place to convert VB.Net to C# and vice versa
http://www.developerfusion.co.uk/utilities/convertvbtocsharp.aspx
http://www.developerfusion.co.uk/utilities/convertvbtocsharp.aspx
ASKER
Thanks again for the help; got it working.
You welcome Deon
findcontrol method is discussed here
http://www.odetocode.com/Articles/116.aspx
Good luck