2012-02-24 51 views
0

我试图在单个中继器中显示图像和视频。 为此,我在aspx页面中使用if else。但是这不会带来任何价值。任何人都可以帮我解决这个问题吗?我无法使用If ... Else在我的aspx页面

<% 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") %>' /> 
} %> 

回答

4

尝试这样的事情,而不是;

<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") %>" /> 
+0

请变更<%=的eval( “UploadType”)..%>与<%#%表达> – adatapost 2012-02-24 13:38:38

+0

谢谢。它的工作非常好 – user1230825 2012-02-24 14:18:58

-1

试试这个

<% 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") %>' /> 
<% } %> 
-1

使用它像这样...

<% 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") %>' /> 
<% } %> 
相关问题