Placing code behind code in the aspx page
Hi i have a variable which i am setting in the code behind which is
protected int intPermission;
In my aspx page I have this piece of code
<% if (Page.User.Identity.IsAuthenticated)
{ %>
<span class="feed_link">
<a class="comment reply"></a>
</span>
<%} 开发者_运维百科%>
I am trying to add the intPermission variable in the if statement however i am getting syntax errors.
I want it to be like this
if (Page.User.Identity.IsAuthenticated && intPermission == 1 || Page.User.Identity.IsAuthenticated && intPermission == 2)
How do i go about doing this?
Use a PlaceHolder
. Then use its Visible
property to set it from the code behind.
Change it to public
public int intPermission;
And perhaps use brackets in the if-statement
if ((Page.User.Identity.IsAuthenticated && intPermission == 1) || (Page.User.Identity.IsAuthenticated && intPermission == 2))
精彩评论