User Control method access

T

tshad

I am trying to access a method from outside my User Controls and am getting
an error:

Compiler Error Message: BC30456: 'FillGrids' is not a member of
'System.Web.UI.Control'.

I have the method defined as "Public" in my control:
********************************************
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<script runat="server">
Sub Page_Load(sender as Object, e as EventArgs)
if not IsPostBack
Call FillGrids()
end if
end sub

Public Sub FillGrids()
....
End Sub
*********************************************

My aspx page (actually another control) is:
****************************************************
<script runat="server">
Sub Page_Load(sender as Object, e as EventArgs)
trace.warn("UserID = " & session("UserID"))
dim IsCheckResumes as Boolean = true
Dim pageControl As Control = LoadControl("RolesAdmin.ascx")
PageUserControl.Controls.Add(pageControl)
Call pageControl.FillGrids() <--- The
error

....

<asp:placeHolder ID="PageUserControl" runat="server"/>
****************************************************

I would also like to be able to access the Method from the PlaceHolder since
I may call it from other functions in my page where the control is not
defined (but the PlaceHolder would be. Something like:

Call PageUserControl.Controls.?.FillGrids()

Do I need define the control differently?

Thanks,

Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top