2012-02-24 25 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") %>' /> 
<% } %> 
相關問題