簡體   English   中英

將代碼放在aspx頁面中的代碼后面

[英]Placing code behind code in the aspx page

嗨我有一個變量,我在后面的代碼設置是

protected int intPermission;

在我的aspx頁面中,我有這段代碼

  <% if (Page.User.Identity.IsAuthenticated)
       { %>
        <span class="feed_link">
            <a class="comment reply"></a>
        </span>
    <%} %>

我試圖在if語句中添加intPermission變量但是我得到語法錯誤。

我希望它是這樣的

if (Page.User.Identity.IsAuthenticated && intPermission == 1 || Page.User.Identity.IsAuthenticated && intPermission == 2)

我該怎么做呢?

使用PlaceHolder 然后使用其Visible屬性從后面的代碼中設置它。

將其更改為公開

public int intPermission;

也許在if語句中使用括號

if ((Page.User.Identity.IsAuthenticated && intPermission == 1) || (Page.User.Identity.IsAuthenticated && intPermission == 2))

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM