根据html上的userAuthentication使Panel可见 [英] Making a Panel visible based on userAuthentication on html

查看:73
本文介绍了根据html上的userAuthentication使Panel可见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi
i将制作一个asp面板,根据userAuthentication可见,但我有一个错误

请帮我看看如何编写此代码

< br $>


我的代码是

hi i will make a asp panel that them visibility based on userAuthentication but i have a error
please help me that how i write this code


my code is

<asp:Panel ID="Panel1" runat="server" Visible='<%= !User.Identity.IsAuthenticated %>'>





但我有错误



无法从字符串表示形式'<%=!User.Identity.IsAuthenticated.ToString()%>'中为'Visible'属性创建'System.Boolean'类型的对象。



but i have a error

Cannot create an object of type 'System.Boolean' from its string representation '<%= !User.Identity.IsAuthenticated.ToString() %>' for the 'Visible' property.

推荐答案

Visible="<%# CheckIsAuthenticated()%>"



在代码中添加以下方法


add below method in code behind

public bool CheckIsAuthenticated()
{
   return !User.Identity.IsAuthenticated;
}


<asp:panel id="Panel1" runat="server" visible="<%# !User.Identity.IsAuthenticated %>" xmlns:asp="#unknown"></asp:panel>


这篇关于根据html上的userAuthentication使Panel可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆