Beispiel #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            try
            {
                xmlpath = Server.MapPath("EditMenu.xml");
                DownLoadXml(sender, e);//下载XML文件至指定路径
                treeMenuPower.Nodes.Clear();
                //新建个DataSource指向要绑定的文件
                XmlDataSource xds = new XmlDataSource();
                xds.DataFile = xmlpath;
                XmlDocument xmlDocument = xds.GetXmlDocument();
                //把根节点和treeView实例根节点群放进去递归
                BindXmlToTreeView(xmlDocument.DocumentElement, treeMenuPower.Nodes);
                if (Request.QueryString["id"] != null && Request.QueryString["id"].ToString() != "")
                {
                    string id       = Request.QueryString["id"].ToString();
                    string rolename = bl.GetRoleNameById(id, out errMsg).ToString();
                    this.lblRoleName.Text = rolename;

                    ShowTreeCheck(id, treeMenuPower.Nodes);
                }
                treeMenuPower.ExpandAll();
            }
            catch
            {
            }
        }
    }
    public static void InsertNode(ASPxTreeList treeList, ASPxDataInsertingEventArgs e)
    {
        XmlDataSource xmlDataXource = treeList.Page.FindControl(treeList.DataSourceID) as XmlDataSource;
        XmlDocument   docum         = xmlDataXource.GetXmlDocument();

        AddNewNodeId(e.NewValues, docum);

        var     parentNodeInTreeList = treeList.FindNodeByKeyValue(treeList.NewNodeParentKey);
        var     parentID             = parentNodeInTreeList.GetValue("Id").ToString();
        XmlNode parentNode           = FindNode(docum, parentID);

        var     level   = Convert.ToInt32(parentNode.Attributes["Level"].Value) + 1;
        XmlNode newNode = docum.CreateElement("Level" + level + "Node");

        foreach (DictionaryEntry entry in e.NewValues)
        {
            newNode.Attributes.Append(GetNewAttribute(docum, entry.Key, entry.Value));
        }

        newNode.Attributes.Append(GetNewAttribute(docum, "Level", level));
        newNode.Attributes.Append(GetNewAttribute(docum, "ParentKey", parentID));

        parentNode.AppendChild(newNode);
        RearrangeAndSaveXml(docum);
    }
        private void bindXML()
        {
            DataSet       ds     = new DataSet();
            XmlDataSource source = Page.Master.FindControl("source") as XmlDataSource;

            ds.ReadXml(new XmlNodeReader(source.GetXmlDocument()));

            dt = ds.Tables[0];
        }
    public static void DragAndDropNode(ASPxTreeList treeList, TreeListNodeDragEventArgs e)
    {
        XmlDataSource xmlDataXource = treeList.Page.FindControl(treeList.DataSourceID) as XmlDataSource;
        XmlDocument   docum         = xmlDataXource.GetXmlDocument();

        XmlNode oldChildNode = FindNode(docum, e.Node.GetValue("Id"));
        XmlNode parentNode   = FindNode(docum, e.NewParentNode.GetValue("Id"));

        ReplaceNode(docum, parentNode, oldChildNode);
        RearrangeAndSaveXml(docum);
    }
Beispiel #5
0
        XDocument LoadDocument()
        {
            XDocument doc = null;

            using (XmlNodeReader reader = new XmlNodeReader(xmlDataSource.GetXmlDocument()))
            {
                reader.MoveToContent();
                doc = XDocument.Load(reader);
            }
            return(doc);
        }
        private void bindXML()
        {
            DataSet       ds     = new DataSet();
            XmlDataSource source = Page.Master.FindControl("source") as XmlDataSource;

            ds.ReadXml(new XmlNodeReader(source.GetXmlDocument()));

            ddlModele.DataSource     = ds;
            ddlModele.DataTextField  = "Name";
            ddlModele.DataValueField = "ID";
            ddlModele.DataBind();
        }
    public static void DeleteNode(ASPxTreeList treeList, ASPxDataDeletingEventArgs e)
    {
        AddHiddenNodeValues(e.Values, e.Keys[0], treeList);

        XmlDataSource xmlDataXource = treeList.Page.FindControl(treeList.DataSourceID) as XmlDataSource;
        XmlDocument   docum         = xmlDataXource.GetXmlDocument();

        XmlNode node = FindNode(docum, e.Values["Id"]);

        node.ParentNode.RemoveChild(node);

        RearrangeAndSaveXml(docum);
    }
Beispiel #8
0
        public static void datafile(Page p)
        {
            string originalxml = @"<?xml version=""1.0"" encoding=""utf-8""?><bookstore xmlns:bk=""urn:samples""><book genre=""novel"" publicationdate=""1999"" bk:ISBN=""0192100262""><title>Pride and Prejudice</title><author><first-name>Jane</first-name><last-name>Austen</last-name></author><price>24.95</price>""
			</book><book genre=""novel"" publicationdate=""1985"" bk:ISBN=""0771008139""><title>The Handmaid's Tale</title><author><first-name>Margaret</first-name><last-name>Atwood</last-name></author><price>29.95</price></book></bookstore>"            ;

            XmlDataSource ds = new XmlDataSource();

            p.Form.Controls.Add(ds);
            ds.DataFile = "~/XMLDataSourceTest.xml";
            ds.DataBind();
            string derivedxml = ((XmlDocument)ds.GetXmlDocument()).InnerXml;

            HtmlDiff.AssertAreEqual(originalxml, derivedxml, "Loading xml");
        }
        private void bindXML()
        {
            XmlDataSource source = Page.Master.FindControl("source") as XmlDataSource;

            ds.ReadXml(new XmlNodeReader(source.GetXmlDocument()));

            DataTable dt = ds.Tables[0];

            dt = buildTable(dt);

            Grid.ShowHeader = false;
            Grid.DataSource = dt;
            Grid.DataBind();
        }
Beispiel #10
0
	protected void Page_Load (object sender, EventArgs e)
	{
		XmlDataSource xmlds = new XmlDataSource ();

		xmlds.DataFile = "./dialogbeispiel.xml";
		XmlDocument xmldoc = xmlds.GetXmlDocument ();
		XmlNodeList xmlnl = xmldoc.GetElementsByTagName ("button");

		foreach (XmlNode node in xmlnl) {
			Button tmp = new Button ();
			tmp.Text = node.FirstChild.InnerText;
			tmp.ID = node.ChildNodes [1].InnerText;
			PlaceHolder1.Controls.Add (tmp);
		}
	}
    public static void UpdateNode(ASPxTreeList treeList, ASPxDataUpdatingEventArgs e)
    {
        AddHiddenNodeValues(e.NewValues, e.Keys[0], treeList);

        XmlDataSource xmlDataXource = treeList.Page.FindControl(treeList.DataSourceID) as XmlDataSource;
        XmlDocument   docum         = xmlDataXource.GetXmlDocument();

        XmlNode node = FindNode(docum, e.NewValues["Id"]);

        foreach (DictionaryEntry entry in e.NewValues)
        {
            if (entry.Key.ToString() != "Id")
            {
                node.Attributes[entry.Key.ToString()].Value = entry.Value.ToString();
            }
        }
        RearrangeAndSaveXml(docum);
    }
        protected void Grid_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "DodajRecenzje")
            {
                string url   = "Recenzja.aspx";
                string param = "";
                string model = "";

                DataSet       ds     = new DataSet();
                XmlDataSource source = Page.Master.FindControl("source") as XmlDataSource;
                ds.ReadXml(new XmlNodeReader(source.GetXmlDocument()));

                int index = Convert.ToInt32(e.CommandArgument);
                model = ds.Tables[0].Rows[index][0].ToString();

                param  = "?";
                param += "model=" + model;
                param += "&";
                param += "tryb=" + "direct";

                Server.Transfer(url + param);
            }
        }
Beispiel #13
0
    //加载XML文件
    protected void LoadXml(string xmlPathS)
    {
        treeMenuPower.Nodes.Clear();
        //xmlpath = FileUpload1.PostedFile.FileName.ToString();
        xmlpath = xmlPathS;
        Session.Contents["xmlpath"] = xmlpath;
        XmlDataSource xds = new XmlDataSource();

        xds.DataFile = xmlpath;
        XmlDocument xmlDocument = xds.GetXmlDocument();

        //把根节点的东东和treeView实例根节点群丢进去递归
        BindXmlToTreeView(xmlDocument.DocumentElement, treeMenuPower.Nodes);
        if (Request.QueryString["id"] != null && Request.QueryString["id"].ToString() != "")
        {
            string id       = Request.QueryString["id"].ToString();
            string rolename = id;
            this.lblRoleName.Text = rolename;

            ShowTreeCheck(rolename, treeMenuPower.Nodes);
        }
        treeMenuPower.ExpandAll();
    }
Beispiel #14
0
 //加载XML文件
 protected void LoadXml(string xmlPathS)
 {
     TreeView1.Nodes.Clear();
     //xmlpath = FileUpload1.PostedFile.FileName.ToString();
     xmlpath = xmlPathS;
     Session.Contents["xmlpath"] = xmlpath;
     XmlDataSource xds = new XmlDataSource();
     xds.DataFile = xmlpath;
     XmlDocument xmlDocument = xds.GetXmlDocument();
     BindXmlToTreeView(xmlDocument.DocumentElement, TreeView1.Nodes);
     TreeView1.ExpandAll();
 }
Beispiel #15
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            try
            {
                xmlpath = Server.MapPath("EditMenu.xml");
                DownLoadXml(sender, e);//下载XML文件至指定路径
                treeMenuPower.Nodes.Clear();
                //新建个DataSource指向要绑定的文件
                XmlDataSource xds = new XmlDataSource();
                xds.DataFile = xmlpath;
                XmlDocument xmlDocument = xds.GetXmlDocument();
                //把根节点和treeView实例根节点群放进去递归
                BindXmlToTreeView(xmlDocument.DocumentElement, treeMenuPower.Nodes);
                if (Request.QueryString["id"] != null && Request.QueryString["id"].ToString() != "")
                {
                    string id = Request.QueryString["id"].ToString();
                    string rolename = bl.GetRoleNameById(id,out errMsg).ToString();
                    this.lblRoleName.Text = rolename;

                    ShowTreeCheck(id, treeMenuPower.Nodes);
                }
                treeMenuPower.ExpandAll();
            }
            catch
            {

            }
        }
    }
Beispiel #16
0
    //加载XML文件
    protected void LoadXml(string xmlPathS)
    {
        treeMenuPower.Nodes.Clear();
        //xmlpath = FileUpload1.PostedFile.FileName.ToString();
        xmlpath = xmlPathS;
        Session.Contents["xmlpath"] = xmlpath;
        XmlDataSource xds = new XmlDataSource();
        xds.DataFile = xmlpath;
        XmlDocument xmlDocument = xds.GetXmlDocument();
        //把根节点的东东和treeView实例根节点群丢进去递归
        BindXmlToTreeView(xmlDocument.DocumentElement, treeMenuPower.Nodes);
        if (Request.QueryString["id"] != null && Request.QueryString["id"].ToString() != "")
        {
            string id = Request.QueryString["id"].ToString();
            string rolename = id;
            this.lblRoleName.Text = rolename;

            ShowTreeCheck(rolename, treeMenuPower.Nodes);
        }
        treeMenuPower.ExpandAll();
    }
Beispiel #17
0
        /// <summary>
        /// Returns an hierarchical bound HTML unordered list
        /// </summary>
        /// <returns></returns>
        private MenuList LoadMenusFromXml()
        {
            // If no datasource or xmlfilename is specified, return empty menu
            if (this.DataSource == null && this.DataSourceID == "" && this.XMLMenuFile == "" && this.xDoc == null)
            {
                return(new MenuList());
            }

            // Else construct a new menu based on datasource
            else
            {
                if (this.xDoc != null)
                {
                }
                else
                {
                    xDoc = new XmlDocument();
                    // If an XmlDataSource is specified, use as binding for menu
                    if (this.DataSource != null)
                    {
                        if (this.DataSource is XmlDataSource)
                        {
                            XmlDataSource source = (XmlDataSource)this.DataSource;
                            xDoc  = source.GetXmlDocument();
                            XPath = source.XPath;
                        }
                        else if (this.DataSource is XmlDocument)
                        {
                            XmlDocument source = (XmlDocument)this.DataSource;
                            xDoc = source;
                        }
                    }
                    /// Else, use the DataSourceID to find the XMLDataSource Control
                    else if (this.DataSourceID != "")
                    {
                        Control con = this.NamingContainer.FindControl(this.DataSourceID);
                        if (con is XmlDataSource)
                        {
                            XmlDataSource source = (XmlDataSource)con;
                            xDoc  = source.GetXmlDocument();
                            XPath = source.XPath;
                        }
                    }

                    // Else, use the file specified by the XMLMenuFile property
                    else
                    {
                        xDoc.Load(this.MapPathSecure(XMLMenuFile));
                    }
                }

                // Setup Main Menu
                MenuList MainMenu = new MenuList();
                MainMenu.ID = this.ID;

                XmlNodeList ParentNodes;
                if (XPath == "")
                {
                    ParentNodes = xDoc.DocumentElement.ChildNodes;
                }
                else
                {
                    ParentNodes = xDoc.SelectNodes(XPath);
                }

                foreach (XmlNode Parent in ParentNodes)
                {
                    RecursiveMenuBind(MainMenu, Parent);
                }
                return(MainMenu);
            }
        }
Beispiel #18
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string param = Request["param"];
        if (param != "")
        {
            if (param == "Add")
            {
                string id = Request.Form["id"];
                string name = Request.Form["name"];
                string src = Request.Form["src"];
                string vis = Request.Form["vis"];
                string dep = Request.Form["dep"];
                BtnAdd_Click(sender,e);
            }
        }
        if (!IsPostBack)
        {

        }
        if (!Page.IsPostBack)
        {
            xmlpath = Server.MapPath("EditMenu.xml");
            DownLoadXml(sender, e);//下载XML文件至指定路径
            TreeView1.Nodes.Clear();
            //Session.Contents["xmlpath"] = xmlpath;
            XmlDataSource xds = new XmlDataSource();
            xds.DataFile = xmlpath;
            XmlDocument xmlDocument = xds.GetXmlDocument();
            BindXmlToTreeView(xmlDocument.DocumentElement, TreeView1.Nodes);
            TreeView1.ExpandAll();
        }
    }