How to do it

  • Thread starter Thread starter Thor W Hammer
  • Start date Start date
T

Thor W Hammer

I made my own server control and try to use it like this:
<my:face runat="server" color="<%= strColor %>"></my:face>

At runtime the color property will get the literal string "<%= strColor%>"
while I was expecting the value of strColor which is i.e. "blue" to appear
in the color property.
Isn't the <%=...%> thing supposed to work with web-controls in this way?
What have I missed?

And by the way, if I want to put it like this: <my:face runat="server"><%=
strColor%></myface>
How can I possibly get the inner content of the control (the value) from
inside the web-control code? I can't find a this.InnerText property.

Thanks for all cool replays!

Kindly regards,
TWH
 
Yes it is true that <%= ..%> is evaluated as you say, the question is - at
what step. It is rendered that way at the very and, and by then you are not
setting the property of the server control - at the server. Subscribe to all
page events and check the property value of that particular control
instance - you'll immediately see the problem.


- Sahil Malik [MVP]
ADO.NET 2.0 book -
http://codebetter.com/blogs/sahil.malik/archive/2005/05/13/63199.aspx
 
Thor,

I am not sure if I understand you, however if it is what I think, than I add
for this an ID to the control.

I hope this helps,

Cor
 
Thor,

This is not really a AdoNet question, in the you use this is mostly handled
in the newsgroup

microsoft.public.dotnet.framework.aspnet

I think that you there get more answers
(And probably more to the point than my last, however it can be it).

Cor
 
Back
Top