<mi*******@hotmail.comwrote in message
news:11**********************@75g2000cwc.googlegro ups.com...
The FindControl method I was talking about in the other thread....
Label lbl = (Label)Page.FindControl("controlidhere");
or
Label lbl = (Label)Parent.FindControl("controlidhere");
That looks like exactly what I am looking for.
But it doesn't seem to be working or at least it doesn't seem to be getting
called.
I have a control that calls this control.
**************************************
Dim pageInit as Control = LoadControl("/controls/pageInit.ascx")
if pageInit is nothing then
trace.warn("pageInit is nothing")
else
trace.warn("pageInit is not nothing")
end if
********************************************
It seems to be loading as the tras I get is "pageInit is not nothing".
but the code doesn't seem to be working. The code is in the Page_Load
section.
The pageInit.ascx is:
**************************************************
<script runat="server">
Sub Page_Load(s as Object, e as EventArgs)
trace.warn("Inside pageInit.ascx")
Dim UserLoggedOnLabel as Label =
CType(Page.FindControl("UserLoggedOnLabel"),Label)
UserLoggedOnLabel.Text = "this is a test"
if not session("User") is nothing then session("LastPageVisited") =
Session("User").LastPageVisited
End Sub
</script>
**************************************************
The Page_Load in this control doesn't seem to be running.
I don't get the Trace message, the UserLoggedOnLagel doesn't seem to get
changed and the Session("LastPageVisited") doesn't get set.
If I don't have the code you mentioned, I get the error, so I assume the
control is getting loaded.
Am I missing something here?
Thanks,
Tom
>
tshad wrote:
>Is there a way for a User Control to access an object (such as label or
textbox) on the .aspx page that calls it?
For example:
x.aspx
**************************************
...
Sub Page_Load(s as Object, e as EventArgs)
LoadControl("x.ascx")
End Sub
...
<asp:Label ID="theLabel" runat="server"/>
**************************************
x.ascx
**************************************
Sub Page_Load(s as Object,e as EventArgs)
theLabel.Text = "Some Text"
End Sub
****************************************
This would get me the error:
Name 'MessageOutside' is not declared
I know how to access methods and properties in the User Control from the
.aspx page, but not the other way around.
Thanks,
Tom