Codebehind and object declaration

  • Thread starter Thread starter Andrew2
  • Start date Start date
A

Andrew2

I'm a little confused why on codebehind file in asp.net 2.0 I cannot
directly access to the object places on the designer.
I can reach them via FindControl method, but I would like to find some
simply sheed that shows me the correct rules about this aspect of
asp.net programming.

technically I could modify designer.cs file, but it doesn't sound like
a good way. It could happen like in asp.net 1.0 or even 1..1 that a
manual changes affect the final behaviour or the page, or worse,
designer when restart delete changes done manually.

Thanks for your patience.

Andrea
 
Not sure what you meant.

It depends where you put the control. If not inside a naming container
you'll have access to it. If inside a container you won't as for example
you'll have multiple instances, once for each bounded row.

I'm not sure though what you meant by "directly access to the object places
on the designer" ? As you talk also about FindControl my understanding is
that you meant "using the variable that represents the control" ?
 
Not sure what you meant.
my understanding is that you meant "using the variable that represents the control" ?

Exactly what I want to say. Imagine the code below.

<asp:FormView ID="FormView1" runat="server"
DataSourceID="ProductDataSource"
OnDataBound="FormView1_DataBound">
<ItemTemplate>
<asp:Image ID="Image1" runat="server" />
<asp:Label ID="Notes" runat="server" />
<asp:Panel ID="colorsPanel"
runat="server">
<asp:Repeater ID="ColorList" runat="server">


Well, in the codefiel I would like to simple do ColorList. .... and
get method and properties. But a FormView should be a naming container
and so I suppose that is impossible.

Why is not really clear ... where can I find more info about this
aspect? A specific link on MSDN or something around the net.

Thanks
Andrea
 
I would recommend against this tip or at least you may want to know that
this delimited can change depending what is the (X)HTML standard you are
looking for.

When you search for a control in the appropirate event, you don't have AFAIK
in most cases to take into account the hierarchy as you are already well
placed...
 
Back
Top