Пример #1
0
        private static SiteMapProvider CreateProvider()
        {
            SiteMapProvider xmlProvider = new XmlSiteMapProvider();

            xmlProvider.Initialize("internal", new NameValueCollection {
                { "securityTrimmingEnabled", "true" }, { "siteMapFile", "Web.sitemap" }
            });

            return(xmlProvider);
        }
Пример #2
0
        public ActionResult Menu()
        {
            XmlSiteMapProvider  testXmlProvider    = new XmlSiteMapProvider();
            NameValueCollection providerAttributes = new NameValueCollection(1);

            providerAttributes.Add("siteMapFile", "Web.sitemap");
            testXmlProvider.Initialize("menuProvider", providerAttributes);
            var collection = testXmlProvider.GetChildNodes(testXmlProvider.RootNode);

            return(PartialView(collection));
        }
Пример #3
0
    private SiteMapDataSource GetSiteMapDataSource()
    {
        XmlSiteMapProvider xmlSiteMap = new XmlSiteMapProvider();

        System.Collections.Specialized.NameValueCollection myCollection = new System.Collections.Specialized.NameValueCollection(1);
        myCollection.Add("siteMapFile", "Web.sitemap");
        xmlSiteMap.Initialize("provider", myCollection);
        xmlSiteMap.BuildSiteMap();

        SiteMapDataSource siteMap = new SiteMapDataSource();

        return(siteMap);
    }
Пример #4
0
    public static SiteMapDataSource  GetSiteMapDataSource(string strRole)
    {
        System.Collections.Specialized.NameValueCollection myCollection = new System.Collections.Specialized.NameValueCollection(1);
        myCollection.Add("siteMapFile", "~/Web.sitemap");

        XmlSiteMapProvider xmlSiteMap = new XmlSiteMapProvider();
        xmlSiteMap.Initialize("provider", myCollection);
        xmlSiteMap.BuildSiteMap();

        SiteMapDataSource siteMap = new SiteMapDataSource();
        siteMap.StartingNodeUrl = "~/" + strRole + "Dummy.aspx";
        siteMap.ShowStartingNode = false;                

        return siteMap;
    }
Пример #5
0
    private void CreateTreeViewWithSqlMapDataSource()
    {
        XmlSiteMapProvider xmlSiteMap = new XmlSiteMapProvider();

        System.Collections.Specialized.NameValueCollection myCollection = new System.Collections.Specialized.NameValueCollection(1);
        myCollection.Add("siteMapFile", "Web.sitemap");
        xmlSiteMap.Initialize("provider", myCollection);
        xmlSiteMap.BuildSiteMap();

        SiteMapDataSource siteMap = new SiteMapDataSource();

        TreeView tree = new TreeView();

        tree.DataSource = siteMap;
        Panel1.Controls.Add(tree);
        Panel1.DataBind();
    }
Пример #6
0
        public static SiteMapDataSource GetSiteMapDataSource(string role)
        {
            string url = String.Empty;

            if (role.Equals("Admin"))
            {
                url = "~/Admin/AdminHomePage.aspx";
            }

            else if (role.Equals("User"))
            {
                url = "~/User/UserHomePage.aspx";
            }

            XmlSiteMapProvider xmlSiteMap = new XmlSiteMapProvider();

            System.Collections.Specialized.NameValueCollection myCollection = new System.Collections.Specialized.NameValueCollection(1);

            myCollection.Add("siteMapFile", "Web.sitemap");

            xmlSiteMap.Initialize("provider", myCollection);

            xmlSiteMap.BuildSiteMap();

            SiteMapDataSource siteMap = new SiteMapDataSource();

            siteMap.StartingNodeUrl = url;

            /* This will not show the starting node and hence giving it
             *
             * the horizontal cool look :)
             *
             * */

            siteMap.ShowStartingNode = false;

            return(siteMap);
        }
Пример #7
0
        private void Inicializar()
        {
            try
            {
                SesionUsu       = (Sesion)Session["Usuario"];
                lblUsuario.Text = SesionUsu.Usu_Nombre;
                ddlUsu_Ejercicio.SelectedValue = SesionUsu.Usu_Ejercicio;
                mnu.NombreMenu    = "MenuTop";
                mnu.UsuarioNombre = SesionUsu.Usu_Nombre;
                mnu.Grupo         = 15939;

                string siteMap  = "ArchivosMenu/Web" + SesionUsu.Usu_Nombre + ".sitemap";
                string fullPath = Path.Combine(Server.MapPath("~"), siteMap);
                if (!File.Exists(fullPath))
                {
                    CNMnu.GenerateXMLFile(mnu, fullPath);
                }

                XmlSiteMapProvider  testXmlProvider    = new XmlSiteMapProvider();
                NameValueCollection providerAttributes = new NameValueCollection(1);
                providerAttributes.Add("siteMapFile", siteMap);
                testXmlProvider.Initialize("MyXmlSiteMapProvider", providerAttributes);
                testXmlProvider.BuildSiteMap();
                SiteMapDataSource smd = new SiteMapDataSource();
                smd.ShowStartingNode  = false;
                smd.Provider          = testXmlProvider;
                SiteMapPath1.Provider = testXmlProvider;
                MenuTop.DataSource    = smd;
                MenuTop.DataBind();
                CNComun.LlenaCombo("pkg_contratos.Obt_Combo_sistemas", ref ddlSistemas, "p_usuario", SesionUsu.Usu_Nombre, ref Listsistema);
            }
            catch (Exception ex)
            {
                //lblMsj.Text = ex.Message;
            }
        }
Пример #8
0
        private void MenuArbol()
        {
            lblMensaje.Text = string.Empty;
            try
            {
                mnu.NombreMenu    = "MenuTop";
                mnu.UsuarioNombre = SesionUsu.Usu_Nombre;
                mnu.Grupo         = 15939;
                string siteMap  = "ArchivosMenu/Web" + SesionUsu.Usu_Nombre + ".sitemap";
                string fullPath = Path.Combine(Server.MapPath("~"), siteMap);
                if (!File.Exists(fullPath))
                {
                    CNMnu.GenerateXMLFile(mnu, fullPath);
                }

                XmlSiteMapProvider  testXmlProvider    = new XmlSiteMapProvider();
                NameValueCollection providerAttributes = new NameValueCollection(1);
                providerAttributes.Add("siteMapFile", siteMap);
                testXmlProvider.Initialize("MyXmlSiteMapProvider", providerAttributes);
                testXmlProvider.BuildSiteMap();
                SiteMapDataSource smd = new SiteMapDataSource();
                smd.Provider       = testXmlProvider;
                trvMenu.DataSource = smd;
                trvMenu.DataBind();
                trvMenu.CollapseAll();
                trvMenu.Nodes[0].Expanded = true;



                //trvMenu.Nodes[1].Expanded = true;
            }
            catch (Exception ex)
            {
                lblMensaje.Text = ex.Message;
            }
        }
Пример #9
0
 private SiteMapDataSource GetSiteMapDataSource()
 {
     XmlSiteMapProvider xmlSiteMap = new XmlSiteMapProvider();
     System.Collections.Specialized.NameValueCollection
            myCollection = new
            System.Collections.Specialized.NameValueCollection(1);
     myCollection.Add("siteMapFile", "Web.sitemap");
     xmlSiteMap.Initialize("provider", myCollection);
     xmlSiteMap.BuildSiteMap();
     SiteMapDataSource siteMap = new SiteMapDataSource();
     siteMap.ShowStartingNode = false;
     return siteMap;
 }