Strange ascx compilation error

  • Thread starter Thread starter Daisy
  • Start date Start date
D

Daisy

Strange one here, got an ascx with the following line in it:

<asp:Image id="galleryPhoto" runat="server" ImageUrl="<%# Gallery.Filename
%>" />

All works fine, and my Gallery object has a Filename property.
I've just added Gallery.Directory, and changed the above line to this:

<asp:Image id="galleryPhoto" runat="server" ImageUrl="<%# Gallery.Directory
%>/<%# Gallery.Filename %>" />

And now get the error

CS1040: Preprocessor directives must appear as the first non-whitespace
character on a line

I tried changing them both to .Filename, in case I'd forgotten to completely
add the Directory property, but still the same. I tried adding "/Thumbs/"
instead of just a "/" between the two, since it works in another control
(not an ASP:Image) that looks like this:

<img src="Photos/<%# Photo.Gallery.Directory%>/Thumbs/<%# Photo.Filename %>"
alt="<%# Photo.Title %>" />

Anyone ever come across this before?
 
try this:
<asp:Image id="galleryPhoto" runat="server" ImageUrl="<%# Gallery.Directory
+ "/" + Gallery.Filename %>" />

You're probably hitting some sort of bug in the aspx-to-C# converter, where
it's not generating correct C# source code.
 
Can you look at the source code that the ASP.NET csharp compiler generates?
Or send it so that we can see what is wrong with the code?

Grant Richins said:
try this:
<asp:Image id="galleryPhoto" runat="server" ImageUrl="<%# Gallery.Directory
+ "/" + Gallery.Filename %>" />

You're probably hitting some sort of bug in the aspx-to-C# converter, where
it's not generating correct C# source code.
 
Sankar Nemani said:
Can you look at the source code that the ASP.NET csharp compiler generates?
Or send it so that we can see what is wrong with the code?

If you explain how to do it, maybe... I've not been poking around in things
I didn't write yet :D
 
When you get the error message in the web page the error message contains
the path to the file it generated. And more over ther is a link to see the
source code on the error page.
 
Sankar Nemani said:
When you get the error message in the web page the error message contains
the path to the file it generated. And more over ther is a link to see the
source code on the error page.

Right, here's a saved copy of the source of that page. Code expands when you
click the link:

http://dannytuppeny.co.uk/error.htm

What's commented as Line 6 of Gallery.ascx is:

Line 34: #line 6
"http://localhost/MySite/Gallery/Controls/Gallery.ascx"
Line 35: protected System.Web.UI.WebControls.Image galleryPhoto;

Which doesn't look like it'd cause that error at all... Any suggestions?
 
Daisy said:
Right, here's a saved copy of the source of that page. Code expands when you
click the link:

http://dannytuppeny.co.uk/error.htm

What's commented as Line 6 of Gallery.ascx is:

Line 34: #line 6
"http://localhost/MySite/Gallery/Controls/Gallery.ascx"
Line 35: protected System.Web.UI.WebControls.Image galleryPhoto;

Which doesn't look like it'd cause that error at all... Any suggestions?

Ah, I see, lots of bits of code reference that same line...

It's gotta be this bit:

Line 154: #line 6
"http://localhost/MySite/Gallery/Controls/Gallery.ascx"
Line 155: target.ImageUrl =
System.Convert.ToString(Gallery.Directory %>/<%# Gallery.Filename);

Does this suggest a bug in what isn't my code? :(
 
Grant Richins said:
try this:
<asp:Image id="galleryPhoto" runat="server" ImageUrl="<%# Gallery.Directory
+ "/" + Gallery.Filename %>" />

You're probably hitting some sort of bug in the aspx-to-C# converter, where
it's not generating correct C# source code.

<asp:Image id="galleryPhoto" runat="server" ImageUrl="<%# Gallery.Directory
+ "/" + Gallery.Filename %>" />

This gives "The server tag is not well formed." :o(
 
You have this
<asp:Image id="galleryPhoto" runat="server" ImageUrl="<%#Gallery.Directory>
+ "/" + Gallery.Filename %>" />
try this instead (try this as is and see)
<asp:Image id="galleryPhoto" runat="server" ImageUrl=<%#Gallery.Directory +
"/" + Gallery.Filename %> />

sorry for the delayed response
Sankar Nemani
 
Sankar Nemani said:
You have this
<asp:Image id="galleryPhoto" runat="server"
ImageUrl= said:
+ "/" + Gallery.Filename %>" />
try this instead (try this as is and see)
<asp:Image id="galleryPhoto" runat="server" ImageUrl=<%#Gallery.Directory +
"/" + Gallery.Filename %> />

sorry for the delayed response

No problem, you sorted it!

Looks meesy without the quotes, but it's only a server tag!

Thanks :)
 
Back
Top