ASPX if then else syntax

C

Craig Buchanan

I would like to have logic like this in my aspx page:

<% If DataBinder.Eval(Container, "DataItem.TypeId")=1 Then %>
<A href='objects.aspx?id=<%# DataBinder.Eval(Container, "DataItem.Id") %>'>
<%# DataBinder.Eval(Container, "DataItem.Title") %>
</A>
<% Else %>
<A href='javascript:View("?id=<%# DataBinder.Eval(Container, "DataItem.Id")
%>",600,800);'>
<%# DataBinder.Eval(Container, "DataItem.Title") %>
</A>
<% End If %>

Unfortunately, I get a compilation error when I try to run the app. What is
the correct syntax?

Thanks,

Craig
 
K

Konrad Rotuski

try this :
<% If DataBinder.Eval(Container.DataItem, "TypeId")=1 Then %>
<A href='objects.aspx?id=<%# DataBinder.Eval(Container.DataItem, "Id") %>'>
<%# DataBinder.Eval(Container.DataItem, "Title") %>
</A>
<% Else %>
<A href='javascript:View("?id=<%# DataBinder.Eval(Container.DataItem, "Id")
%>",600,800);'>
<%# DataBinder.Eval(Container.DataItem, "Title") %>
</A>
<% End If %>

HTH
 

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