user1230825
user1230825

Reputation: 27

I am not able to use If...Else inside my aspx page

I am trying to show both image and Video in a single repeater. For that i am using if else inside my aspx page. But this is not return any value. Can anyone help me to resolve the issue?

<%  if('<%#Eval("UploadType").%> == "V"')
{
  <embed src='<%# Eval("FilePath") %>' 
     type="application/x-shockwave-flash" 
     allowscriptaccess="always" 
     allowfullscreen="true" width="150" height="150"></embed>
}
else
{
    <asp:ImageButton ID = "ibtnHolder" runat = "server" 
        Width = "130" Height = "130" 
        ImageUrl = '<%# Eval("FilePath") %>' />
} %>

Upvotes: 0

Views: 1300

Answers (3)

Stefan
Stefan

Reputation: 5672

Try something like this instead;

<embed src='<%# Eval("FilePath") %>' 
    type="application/x-shockwave-flash" 
    allowscriptaccess="always" 
    allowfullscreen="true" 
    width="150" height="150" runat="server" 
    Visible="<%= Eval("UploadType") == "V") %>"></embed>

<asp:ImageButton ID="ibtnHolder" runat="server" 
    Width="130" Height="130" 
    ImageUrl='<%# Eval("FilePath") %>' 
    Visible="<%= Eval("UploadType") != "V") %>" />

Upvotes: 4

Stone Cold
Stone Cold

Reputation: 216

Use it like this...

 <%  if('<%#Eval("UploadType").%> == "V"')
{ %>
<embed src='<%# Eval("FilePath") %>' 
    type="application/x-shockwave-flash" 
    allowscriptaccess="always" 
    allowfullscreen="true" width="150" height="150"></embed>
<% }
else
{ %>
<asp:ImageButton ID = "ibtnHolder" runat = "server" 
    Width = "130" Height = "130" 
    ImageUrl = '<%# Eval("FilePath") %>' />
<% } %>

Upvotes: -1

scibuff
scibuff

Reputation: 13755

try this

<%  if( <%# (Eval("UploadType") == "V") %> )
{ %>
    <embed src='<%# Eval("FilePath") %>' 
        type="application/x-shockwave-flash" 
        allowscriptaccess="always" 
        allowfullscreen="true" width="150" height="150"></embed>
<% }
else
{ %>
    <asp:ImageButton ID = "ibtnHolder" runat = "server" 
        Width = "130" Height = "130" 
        ImageUrl = '<%# Eval("FilePath") %>' />
<% } %>

Upvotes: -1

Related Questions