我在ASP.NET網頁中有這樣的代碼,但是當我運行它時出現錯誤。Eval()和表達式代碼
> Databinding methods such as Eval(), XPath(), and Bind() can only
> be used in the context of a databound control.
問題在哪裏?
<% if (Helpers.GetInt(Eval("Price")) != 0)
{ %>
<input type="button" name="btnSignUp" value="Sign Up - Plimus »" onclick="window.location='<%#Eval("BuyUrl2")%><%= Common.GetUserIdUrl("&","custom_user_id") %>'" />
<% } %>
我得到線錯誤代碼
<%,如果(Helpers.GetInt(EVAL( 「價格」))!= 0)
我完全直放站代碼如下。正如我早說的,除了IF
聲明外,此代碼中的所有內容均可正常工作。我想評估PRICE
,如果是!=0
顯示按鈕的html代碼。
<ItemTemplate>
<div class="row">
<div class="col title">
<%#Eval("Title")%>
</div>
<hr/>
<div class="col price">
<%#string.Format("{0} USD/{1} </br> Instant activation", Helpers.GetDecimal(Eval("Price")).ToString("N"), Portal.GetMembershipTypeLabel(Helpers.GetInt(Eval("Credits"))))%>
</div>
<div class="col">
<input type="button" name="btnSignUp" value="Sign Up - PayPal »" onclick="window.location='<%#Eval("BuyUrl1")%><%= Common.GetUserIdUrl("&","custom_user_id") %>'" />
<br />
<br />
<% if (Helpers.GetInt(Eval("Price")) != 0)
{ %>
<input type="button" name="btnSignUp" value="Sign Up - Plimus »" onclick="window.location='<%= Eval("BuyUrl2")%><%= Common.GetUserIdUrl("&","custom_user_id") %>'" />
<% } %>
</div>
<hr/>
</div>
</ItemTemplate>
你嘗試:'<%=的eval( 「BuyUrl2」)%>'呢? – Icarus
@Icarus IF線出現異常 – Tomas
Tomas能否顯示完整的aspx文件? –