Refresh your screen. I colored the code in question in RED.
Printable View
Refresh your screen. I colored the code in question in RED.
You know even if I reference it this way I still get the same error?
Code:Imports DotIntranet.MainAnnouncement
Public Class accounting
Inherits System.Web.UI.Page
Protected WithEvents lblDate As System.Web.UI.WebControls.Label
Protected WithEvents lblDept As System.Web.UI.WebControls.Label
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim MainAnnouncement1 As New DotIntranet.MainAnnouncement()
lblDate.Text = Today.ToLongDateString
'Here we get the data necessary to fill the User Coctrol via properties.
MainAnnouncement1.imgMain.ImageUrl = "test"
End Sub
End Class
Ok what the problem seems to be is that Page does not expose the User Control. So I think you may need to dynamically load the control from the class.(ie remove the <ucr1:myControl blah/> part.
And in code behind you can load the ascx
Dim blah As MainAnnouncement = LoadControl("MainAnnouncement.ascx")
then you should be able to do what you need.
I don't know why but a friend of mine suggested declaring it this way and it works now.
Code:Protected MainAnnouncement1 As New MainAnnouncement()
Here is my friend's explanation.
You must use the object id in the html code of the aspx hosting page.
For example, a control named mycontrol will be given an id "Mycontrol1".
In the code behind page, declare a protected member of mycontrol named
Mycontrol1.
protected mycontrol Mycontrol1;
....
Mycontrol1.Name = "Test";
weird. Shouldnt make a difference I would have thought.. Oh well. :cool:Quote:
Originally posted by jesus4u
I don't know why but a friend of mine suggested declaring it this way and it works now.
Code:Protected MainAnnouncement1 As New MainAnnouncement()
:cool: and thanks for your help as usual ...;)Quote:
Originally posted by Cander
weird. Shouldnt make a difference I would have thought.. Oh well. :cool:
This is getting fun :D
:pQuote:
Originally posted by jesus4u
This is getting fun :D
i am so very confused all i have to say is -> The Protected keyword confers protected access on one or more declared programming elements. Protected elements are accessible only from within their own class or from a derived class. Protected access is not a superset of friend access.
The Protected keyword can be used in conjunction with the Friend keyword in the same declaration. This combination confers both friend and protected access on the declared elements, so they are accessible from the same assembly, from their own class, and from any derived classes.
or is it something i missed.... oh Cander that Poke thing is distracting man i kept lossing track of what I was reading cause i was afraid it was going to poke me