I presume that the parent of usercontrol is a Panel then your code in usercontrol might be,
CType(Me.Parent,Panel).GroupingText="Test"
__avd
Posting Genius (adatapost)
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241
Firstly add a code-file into your project which must be a subclass of System.Web.UI.Page class.
MyPage.vb (in app_code folder)
Public MustInherit Class MyPage
Inherits System.Web.UI.Page
Public MustOverride Property MyText() As String
End Class
Code & markup of Usercontrol.
TestControl.ascx
<%@ Control Language="VB" ClassName="TestControl" %>
<script runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Dim method As MyPage = CType(Me.Page, MyPage)
method.MyText = "Hello"
End Sub
</script>
Webform - Make sure that the .aspx page directive includes Inherits="MyPage" attribute.
TestPage.aspx
<%@ Page Language="VB" Inherits="MyPage" %>
<%@ Register src="TestControl.ascx" tagname="TestControl" tagprefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Public Overrides Property MyText() As String
Get
Return TextBox1.Text
End Get
Set(ByVal value As String)
TextBox1.Text = value
End Set
End Property
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<uc1:TestControl ID="TestControl1" runat="server" />
</div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</form>
</body>
</html>
__avd
Posting Genius (adatapost)
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241
use this funtion to find the control
Private Shared Function FindControlRecursive(ByVal Root As Control, ByVal Id As String) As Control
If Root.ID = Id Then
Return Root
End If
For Each Ctl As Control In Root.Controls
Dim FoundCtl As Control = FindControlRecursive(Ctl, Id)
If FoundCtl IsNot Nothing Then
Return FoundCtl
End If
Next
Return Nothing
End Function
Find the control with the next statement
Dim lbl As Label = FindControlRecursive(Page.Master, "yourControlID")
4advanced
Junior Poster in Training
67 posts since Nov 2008
Reputation Points: 33
Solved Threads: 10