I was working with an image button the other day and for the life of me I couldn't get rid of a runtime error when it went to load the control. I had a dynamic URL that was something similar to this:
1: ImageUrl='../ImageHandler.ashx?File=<%#Eval("Path") %>&MaxSize=<%=PhotoMaxSize %>&ApplyWaterMark=<%=ApplyWatermark %>'
The problem with this is that when the .Net Framework goes to parse this property it first see the "../*" and then goes down a routine to parse the path out, BUT forgets about the fact that I might have something in the URL that needs to be resolved. It did take me quite a while to figure out what was going on and why the "resolved " path was the same as what was between the quotes.
My solution was to change it up just a little bit, here is what I ended up with:
1: ImageUrl='<%# string.Format("../ImageHandler.ashx?File={0}&MaxSize={1}&ApplyWaterMark={2}", Eval("Path"), PhotoMaxSize, ApplyWatermark) %>' The result is the same but I just used a little help from the oh so nice string.Format method. Now because the URL didn't start with "../" or even "~/" it looked and noticed that it needed to resolve what is in the <%#...%>. On a side note this also applies to the other properties on the control and i would assume that other controls are handled the same way.
I don't know maybe I should have known this before now.