Como buscar un dato de ((SiteMapNode) Container.DataItem).ChildNodes desde el .cs

FerSal68 21 Reputation points
2021-06-23T17:32:38.427+00:00

Buenas!
genere un Web.Sitemap y este tiene "Roles"

en mi Pagina.ASPX coloque un Repeater
108741-image.png

<asp:Repeater runat="server"
DataSource='<%# ((SiteMapNode) Container.DataItem).ChildNodes %>'>
<HeaderTemplate>
<ul class="detalle" >
</HeaderTemplate>
<ItemTemplate>
<li>
<asp:HyperLink runat="server" Visible= '<%#Visible()%>'
NavigateUrl='<%# Eval("Url") %>'>
<%# Eval("Title") %></asp:HyperLink>
</li>

en el HyperLink solo quiero que quede visible aquellos que el usuario pueda ver.
por eso : Visible= '<%#Visible()%>'

cuando voy a escribir Pagina.CS
108677-image.png

namespace Pagina
{

public partial class Pagina : System.Web.UI.MasterPage  
{  
        public new bool Visible()  
    {  
        if (Eval("Roles") == Session["Perm"])  
        {  
            return false;  
        }  
        else  
        {  
            return true ;  
        }  


    }  

no me trae la información (Eval("Roles") , ¿como es para traer la información de esa línea?, del Web.sitemap

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,240 questions
0 comments No comments
{count} votes

Accepted answer
  1. Yijing Sun-MSFT 7,061 Reputation points
    2021-06-24T07:00:50.027+00:00

    Hi @FerSal68 ,
    As far as I think,you could create multiple sitemaps for different users.You could use SiteMapProvider to bind the repeater and according to user's role, bind their own separate sitemap files.
    By the way,please use english.
    More details,you could refer to below articles:
    https://www.codeproject.com/Articles/669717/How-to-correctly-use-sitemap-for-top-left-menus
    https://forums.asp.net/t/1190968.aspx?Menu+sitemap+and+Repeater+control+
    Best regards,
    Yijing Sun


    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our  documentation  to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful