I have a ASP-WebForm-Application with several User-Rights.
In CodeBehind I am hiding some Elements if the specific Rights aren't given. But with F12 the User could manipulate the Code the get some Functionallity he isn't allowed to.
Are there any possibilities to hide Elements from CodeBehind, that they aren't make visible via Code-Manipulation? Something like destroying them completely in CodeBehind?
For example a Navigation based an List-Element, where I want to hide some Links:
<ul>
<li>
<a>link 1<a/>
</li>
<li>
<a>link 2<a/>
</li>
<li>
<a>link 3<a/> // Has to be hidden by some conditions
</li>
</ul>
Hope someone could help me!
You can use the asp:PlaceHolder
or the asp:Panel
and warp your content and make it visible or not.
Alternative you can add on the element the runat="server" Visible="false"
and manipulate the visible.
Examples:
<ul>
<li>
<a>link 1<a/>
</li>
<li>
<a>link 2<a/>
</li>
<li runat="server" id="pnlToHide">
<a>link 3<a/> // Has to be hidden by some conditions
</li>
</ul>
or
<ul>
<li>
<a>link 1<a/>
</li>
<li>
<a>link 2<a/>
</li>
<asp:PlaceHolder runat="server" ID="pnlToHide2">
<li>
<a>link 3<a/> // Has to be hidden by some conditions
</li>
</asp:PlaceHolder>
</ul>
and on code behind
pnlToHide.Visible = false;