question

FerSal68-3387 avatar image
0 Votes"
FerSal68-3387 asked FerSal68-3387 commented

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

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


dotnet-aspnet-generaldotnet-aspnet-webformsdotnet-aspnet-webpages
image.png (14.1 KiB)
image.png (8.6 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

YijingSun-MSFT avatar image
0 Votes"
YijingSun-MSFT answered FerSal68-3387 commented

Hi @FerSal68-3387 ,
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.

· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.



Hello, there is no possibility of seeing when reaching the line of the sitemap, to see what role it has to make a purchase and return True or False, this way I can use a single sitemap and I want to handle Session by the database that comes Oracle Database 11

0 Votes 0 ·

Hi @FerSal68-3387 ,
I suspect you've fallen into the trap, in believing that the roles attribute restricts visibility of the nodes. It doesn't, it actually widens visibility. All restrictions are done with the standard section in web.config.
Just like this:
https://web.archive.org/web/20130408064047/http://ipona.com/asp-net-site-maps-security-trimming-and-roles/
Best regards,
Yijing Sun

0 Votes 0 ·

good!! ok thanks, you have a link to do the session setting step by step, I am doing something wrong or I am missing setting since I am not saving the variables

0 Votes 0 ·