会话变量不起作用 [英] session variable not working

查看:72
本文介绍了会话变量不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<%if(Session ["user"] =="admin"){%>
html代码
<%}%>
但它不起作用

请帮我弄错的地方

在此先感谢

请在aspx.cs文件中告诉我如何执行此操作.我正在使用数据列表,并且该数据列表下有一个图像(删除).
我想在每个评论的旁边显示删除按钮,并为单个管理员用户显示删除按钮.

请帮助我

<%if(Session["user"]=="admin"){%>
html code
<%}%>
but its not working

please help where i can get wrong

Thanks in advance

Please tell me how to do this in aspx.cs file. I am using datalist and one image(delete) is under the datalist.
i want to show the delete button in side of every comment and show delete button for onle admin user.

please help me

推荐答案

为什么要内联代码?这使您的代码不可读.另外,如果您在后面的代码中执行了此操作,则最好能够使用调试器找出问题所在.您确定它不起作用",并且不是您的变量不是您期望的值吗?我会为编写这样的代码而解雇人们,任何会话变量都必须从一类静态字符串中命名,因为IDE永远不会为您检查拼写错误.我还会将诸如admin之类的值存储为常量.
Why are you putting your code inline ? That makes your code unreadable. Also, if you did this in code behind, you''d be better able to use a debugger to work out what is going wrong. Are you sure it''s ''not working'', and it''s not that your variable is not what you expect ? I''d fire people for writing code like this, any session variables MUST be named from a class of static strings, as the IDE will never check for typos for you. I''d also store values like admin as constants.


我想您可能对ASP和ASP.NET感到困惑,请参阅:

http://www.beansoftware.com/ASP.NET-Tutorials/Classic-ASP-vs-ASP.NET.aspx [ ^ ]

弄清楚.
I guess you are confuse with ASP and ASP.NET refer this:

http://www.beansoftware.com/ASP.NET-Tutorials/Classic-ASP-vs-ASP.NET.aspx[^]

to make it clear.


这篇关于会话变量不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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