The <%= ... %executed during rendering. But the object ImageButton is
created at the very beginning when Page is initialized.
That would explain why it does not work.
You simply can not attach to property of the ImageButton logic that is
executed during rendering. It has not run yet.
---------------------------
<%# GetMyButtUrl() %called binding. To tell you the truth I am not sure
how it works. But my guess the .NET parser simply puts the code ImageUrl =
GetMyButtUrl(); when converts aspx page to C#.
So in your example simply replace <%= with <%# and it might work.
I am saying might because i am not sure how exactly <%# %works and if any
additional things required from the object (in your case ImageButton) to
make it work.
George.
"DC" <dc@upsize.dewr ote in message
news:11******** **************@ 22g2000hsm.goog legroups.com...
Hi,
why does this not work:
<asp:ImageButto n
id="myButt"
runat="server"
OnCommand="myBu tt_kick"
ImageUrl="<% =GetMyButtUrl() %>"
</asp:ImageButton >
( I get src="<% =GetMyButtUrl() %>" in the resulting HTML)
while this (in a DataGrid) works perfectly:
<ItemTemplate >
<asp:ImageButto n
id="myButtInAGr id"
runat="server"
OnCommand="myBu tt_kick"
ImageUrl="<%# GetMyButtUrl() %>">
</asp:ImageButton >
</ItemTemplate>
Regards
DC