473,473 Members | 2,236 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Property. Init and Load. Very strange error.

Hello,

I have a page and two user controls:

Page.aspx

|--- UserControl_1.ascx

|--- UserControl_2.ascx

In UserControl_2 I have a property defined as follows:

' Margin
Private _Margin As Integer
Public Property Margin() As Integer
Get
Return _Margin
End Get
Set(ByVal value As Integer)
_Margin = value
End Set
End Property ' Margin

In UserControl_1 I have the following:

Private Sub MyUserControl2_Init(ByVal sender As Object, ByVal e As
EventArgs) Handles MyUserControl2.Init

MyUserControl2.ID = "MyUserControl2"
MyUserControl2.Margin = 20

End Sub

However, in my UserControl_2 I am only able to access the property
values in Page_Load and not in Page_Init.

Any idea what might be going on?

This is really strange.

Thanks,

Miguel

Feb 26 '07 #1
1 1070
It's the timing of events. All the inits aren't necessarily fired at the
same time. UserControl_1 has to create it's child controls so there's often
a dealy in when those properties are available. When UserControl_1 is
initializing that doesn't mean that UserControl_2 is initialized. In all
likelihood it will come as one of the next events. You may want to try using
the Trace.Write in the various controls so you can dump a message to the
trace log and get a feel for how and when the events are firing.
--

Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

"shapper" <md*****@gmail.comwrote in message
news:11**********************@z35g2000cwz.googlegr oups.com...
Hello,

I have a page and two user controls:

Page.aspx

|--- UserControl_1.ascx

|--- UserControl_2.ascx

In UserControl_2 I have a property defined as follows:

' Margin
Private _Margin As Integer
Public Property Margin() As Integer
Get
Return _Margin
End Get
Set(ByVal value As Integer)
_Margin = value
End Set
End Property ' Margin

In UserControl_1 I have the following:

Private Sub MyUserControl2_Init(ByVal sender As Object, ByVal e As
EventArgs) Handles MyUserControl2.Init

MyUserControl2.ID = "MyUserControl2"
MyUserControl2.Margin = 20

End Sub

However, in my UserControl_2 I am only able to access the property
values in Page_Load and not in Page_Init.

Any idea what might be going on?

This is really strange.

Thanks,

Miguel

Feb 26 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Andy Norman | last post by:
I have a strange problem. When I try to call the input property of the MSXML processor object from VBScript in an ASPX page I get the error "Member not found". The same code (with a few "set"...
2
by: Olaf | last post by:
I have a frameset page witch contains the myFuc() function. The function is accessed from a page in one of the frames in the frameset. An example is shown below. <input...
1
by: John Hunter | last post by:
I've recently had a nasty problem with the "Invalid reference to the property Form" error in subforms - nasty because it doesn't seem to consistently happen to all forms which contain the same...
2
by: Colin Robinson | last post by:
Help please I have an example class called Person with 2 public properties Firstname and Lastname, I cant create a textbox on an asp.net form bound to the Person.Firstname property Can...
6
by: Shimon Sim | last post by:
I have Panel control on the page. I am handling Init event for it. It doesn't seem to fire at all. Why? Thank you Shimon.
3
by: Marty McFly | last post by:
Hello, I have a control class that inherits from System.Web.UI.WebControls.Button. When I drag this control from the "My User Controls" tab in the toolbox onto the form, I want it to reflect the...
2
by: | last post by:
I want to use codebehind to pass property values to a control that I've embedded INSIDE of a user control. In other words, let's say I have the following: MyPage.aspx ....with the following...
4
by: SandyIsCool | last post by:
Hi, I am newbie to asp.net. I have small doubt regarding page life cycle. MSDN documentaion says that init event does blhah, blah load event does blah blah etc. But Id ont see any init or load...
1
by: shapper | last post by:
Hello, I am working on Library which will include various controls. One of these controls has a TextBox. I am using a property named Value to define the TextBox text: ' Value Private...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.