Custom Menu By Role Asp.net

Untuk dapat melakukan cutomisasi seperti ini, 2 file harus di configurasi

1. MasterPage.master

2. MasterPage.master.cs

pada MasterPage.master, setiap link menu beri ID . Contoh :

</pre>
<asp:HyperLink runat="server" NavigateUrl="~/Default.aspx" >Home</asp:HyperLink>
 <asp:HyperLink runat="server" NavigateUrl="~/Kategori/Kategori.aspx" ID="HyperLinkKategori" >Kategori</asp:HyperLink>
 <asp:HyperLink runat="server" NavigateUrl="~/Obat/Daftar_obat.aspx" ID="HyperLinkObat">Obat</asp:HyperLink>
<pre>
 

pada MasterPage.master.cs lakukan setting seperti ini :

 if(Page.User.IsInRole("assisten")){
 HyperLinkObat.Visible = false;
 }
 if (Page.User.IsInRole("admin"))
 {
 HyperLinkObat.Visible = true;
 }
 

maka jika assisten login, maka menu Obat tidak tampil pada menu

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: