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

  • Thread starter Thread starter erin.sebastian
  • Start date Start date
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>
 
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>
 
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
 
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>
 
Back
Top