Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 5th, 2005, 11:18 PM
Registered User
 
Join Date: Jun 2005
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default how can i access controls on parent page from user

 Hello.

How can i access controls declared on the parent page from user controls?
for example, i have a parent page called "main.aspx"

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<%@ Register TagPrefix="MyControl" TagName="UserControl1" Src="myUserControl.ascx" %>


<asp:Button ID="showPanel" Text="ShowPanel" runat="server" />

<asp:Panel ID="Panel1" runat="server" visible="false">

<MyControl:UserControl1 ID="UserControl1" runat="server">
</asp:Panel>



"Default.aspx.vb"

Partial Class _Default
    Inherits System.Web.UI.Page

Protected Sub showPanel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles showPanel_Click
Panel1.visible = true
End Sub
End Class


"myUserControl.ascx"
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="myUserControl.ascx.vb" Inherits="myUserControl" %>

<table>
<tr>
<td>
<asp:Button ID="HidePanel" Text="HidePanel" runat="server" />
</td>
</tr>
</table>

"myUserControl.ascx.vb"

Partial Class _Default
    Inherits System.Web.UI.Page

Protected Sub HidePanel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles HidePanel_Click

' This is the place to hide the panel1 from parent page.

End Sub
End Class


So, this is clear that when i click the HidePanel button, the panel from parent page will be hide.
Please help me. thanks






Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing controls in host page from User Control Axe BOOK: Professional Web Parts and Custom Controls ASP.NET ISBN: 0-7645-7860-X 1 March 16th, 2011 06:22 AM
User controls' content: Chapter 2 User Controls AGS BOOK: Professional ASP.NET 2.0 Server Control and Component Development ISBN: 978-0-471-79350-2 10 July 26th, 2007 05:36 AM
User controls not showing on web page pdr ASP.NET 1.0 and 1.1 Basics 0 August 10th, 2005 09:02 AM
User Controls - Access Correct Poperties rodmcleay ASP.NET 1.0 and 1.1 Professional 8 February 24th, 2005 08:26 PM
Multiple user controls on a page kriskramer General .NET 2 September 14th, 2004 08:42 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.