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 id="face1" 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!

Kind regards,
TWH
 
Should work I think.

Have you tried defining

<my:face id="face1" runat="server" color="Blue" />

to check it's not something to do with the control?
 
The alternative is to fill the property at runtime using code.
Something like <my:face id="face1" runat="server"></my:face>

Sub Page_Load()
face1.Color = Color.Blue
End Sub


Of course you have to modify the example to your own needs.

Cheers,
//Rutger

http://www.RutgerSmit.com
 
Thanks, but I have tried that and it works. I want to get clear if it should
be possible to use the syntax that i described.
 
Back
Top