Object references from aspx to C# ?

M

mAbZ

I have trouble getting an object reference from aspx to c# code.
I have 2 controls created in an aspx page:

....
<MyNamespace:MyControl1 ID="ctrl1" runat="server" ParentWindow="<%# this %>"
/>
<MyNamespace:MyControl2 ID="ctrl2" runat="server" Args="<%# ctrl1 %>" />
....

I also have 2 corresponding classes with their public properties
ParentWindow and Args respectively.

The objects "this" and "ctrl1" are instantiated but while
debugging I see that their values in each property setter are null.
The instantiated object "stays" so to speak on the aspx page.
Why? I would appreciate any ideas.

P.S.
Instatiating those objects in C# instead is working but is not an option,
I need to do it like above.
 
B

bruce barker

as you are using databinding expression, your control has to support
databinding or be inside a control that databinds its children, and you
have to call databind() on the control.

-- bruce (sqlwork.com)
 
M

mAbZ

Ok, so I should call DataBind()in constructor and
have an OnDataBinding()method, right?
I would call base.OnDataBinding()and that's it?
Or should something more happen there in that method?

Thanks for the answer! :)
 

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

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,814
Latest member
SpicetreeDigital

Latest Threads

Top