Asp.net如果声明前端 [英] Asp.net if statement front end

查看:53
本文介绍了Asp.net如果声明前端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<% if((Session["Rol"]).ToString() == "Yönetici")
                         { %>
                                                          <li>

                          <a href="SiparisEkle.aspx">Sipariş Ekle</a>

                      </li>
                       <% } %>





我的尝试:





What I have tried:

Hi how can I do this example. I want to if Role == Yonetici show menu if Role == Depocu dont show menu.

推荐答案

我建​​议不要尝试使用这样的内联代码。这种风格是旧的经典ASP风格,我甚至不确定它在ASP.Net中是否完全有效。首先在你的a标签上输入runat =server并输入id =hypSip,这样你就可以在C#中访问它或者使用asp:HyperLink代替它。



在C#代码隐藏页面的Page_Load事件中,您只需执行

I would suggest not trying to use inline code like that. That style is old classic ASP style and I'm not even sure it fully works in ASP.Net. First put runat="server" on your a tag and id="hypSip" so you can access it in C# or use an asp:HyperLink instead.

In your Page_Load event in C# codebehind page you can simply do
hypSip.Visible = Session["Rol"].ToString() == "Yönetici"; // you may want to check to make sure it is not NULL first to be safe.


这篇关于Asp.net如果声明前端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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