tags:

views:

203

answers:

3

I've created the following function backend:

public string getImageURL()
{
    return "some text";
}

Within my FormView , I have the following code;

<img class="hotelImage floatLeft" src="<% getImageURL(); %>" alt="" />

But I keep getting the CS0103: error. Why is that? I'm pretty sure I've called lots of functions this way in the past.

Update
heh..... this is a bit embarrassing. I discovered I was working on a backup file which is not in use in the solution.... I had opened it to look at some old code... so guess what happened when I added the function to the correct file....

+4  A: 
<img class="hotelImage floatLeft" src="<%= getImageURL() %>" alt="" />
Preet Sangha
I've tried that, doesn't work either.
Steven
@Steven: are you sure you added the = sign after the % and removed the semi-colon? This works for me.
Ahmad Mageed
heh..... this is a bit embarrassing. I discovered I was working on a backup file which is not in use in the solution.... I had opened it to look at some old code... so guess what happened when I added the function to the correct file....
Steven
A: 
<img class="hotelImage floatLeft" src="<%= getImageURL() %>" alt="" />
NinethSense
+1  A: 

If all you need to do is have the URL come from the code-behind, you can just use a protected member instead.

protected string imageUrl = "Some text";

Then in the ASPX you can use

<%= imageUrl %>

to get the desired string.

Secret Agent Man
Thanks for the tip.
Steven