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

E

erin.sebastian

Hello All,
I am writing a webpage in c+ .net and i have a repeater that displays
information, i want to add a statement that says
IF ("title" value from databinder == "Careers") output BLAH (show the
stuff in the databind)
ELSE
output some other BLAH (redirect to a different ASPX but show the
"title" field from the databinder...

but i keep getting the above (in the subject line) error and i can't
figure out why.. can anyone help me out...

(go to the --RIGHT HERE-- tag to see what i've done)..

Thanks in advance!!

<asp:Repeater id="rptSectionDetS" Visible="False" runat="server"
onItemDataBound="ShowSubSections">
<ItemTemplate>
<li <%# validSec(DataBinder.Eval(Container.DataItem,
"sectionId").ToString()) ? "class='current'" : " class=''" %>><a
href="section<%# DataBinder.Eval(Container.DataItem, "layoutId")
%>.aspx?id=<%# DataBinder.Eval(Container.DataItem, "sectionId") %>"><%#
DataBinder.Eval(Container.DataItem, "title") %></a></li>

<asp:Repeater id="rptSubSections" Visible='<%#
validSec(DataBinder.Eval(Container.DataItem, "sectionId").ToString())
%>' runat="server" onItemDataBound="ShowSubPages">
<ItemTemplate>
<li <%# validSubSec(DataBinder.Eval(Container.DataItem,
"subsectionId").ToString()) ? "class='level1hl'" : " class='level1'"
%>>
--RIGHT HERE-- <% if(# DataBinder.Eval(Container.DataItem,
"title").ToString() != "Careers"}{%>
<a href="subsection<%# DataBinder.Eval(Container.DataItem,
"layoutId") %>.aspx?id=<%# DataBinder.Eval(Container.DataItem,
"subsectionId") %>"><%# DataBinder.Eval(Container.DataItem, "title")
%></a></li>
<%}%> -- ADD ELSE EVENTUALLY--

<asp:Repeater id="rptSubPages" Visible='<%#
(validSubSec(DataBinder.Eval(Container.DataItem,
"subsectionId").ToString())) %>' runat="server">
<ItemTemplate>
<li class="level2"><a href="subpage<%#
DataBinder.Eval(Container.DataItem, "layoutId") %>.aspx?id=<%#
DataBinder.Eval(Container.DataItem, "subpageid") %>"><%#
DataBinder.Eval(Container.DataItem, "title") %></a></li>
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:Repeater>
 
L

Lloyd Dupont

OKay, let's analyse this RIGHT HERE line:
<% if(# DataBinder.Eval(Container.DataItem, "title").ToString() !=
"Careers"}{%>

Don't you see anything weird?
Let's remove the ASP stuff:
if(# DataBinder.Eval(Container.DataItem, "title").ToString() != "Careers"}{

Well that's not really valid C++ but the 4th character is a # which probably
hint the compiler it's a preprocessor definition.
but it's in the wrong place...
did you mean
#if DataBinder Eval(....)

or perhaps it's just plain dsyleixc error?
and you mean:
<%# if(DataBinder.Eval(Container.DataItem,"title").ToString() !=
"Careers"}{%>

Anyway none of them is valid anyway...




--
Regards,
Lloyd Dupont

NovaMind development team
NovaMind Software
Mind Mapping Software
<www.nova-mind.com>
 
E

erin.sebastian

Actually i am just a bit new to this, when outputting data from the
databinder you need a # sign so i thought that it went with the
databinder stuff... So if none of them is valid, can you show me which
one IS valid??
Thank you,
Erin
 
L

Lloyd Dupont

Maybe you would have more luck on this newsgroup:
microsoft.public.newsgroups.framework.aspnet

I'm not that good in ASP.NET.
but I do know that while <%# ... %> is valid <% .....#.... %> is not
look in the SDK documentation, maybe there are some tips....

--
Regards,
Lloyd Dupont

NovaMind development team
NovaMind Software
Mind Mapping Software
<www.nova-mind.com>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top