public void Events(Page p) { PokerSiteMapPath smp = new PokerSiteMapPath(); ResetEvents(); smp.DataBinding += new EventHandler(DataBindingHandler); smp.ItemDataBound += new SiteMapNodeItemEventHandler(ItemDataBoundHandler); smp.ItemCreated += new SiteMapNodeItemEventHandler(ItemCreatedHandler); Assert.AreEqual(false, DataBinding, "BeforeDataBinding"); smp.DoOnDataBinding(new EventArgs()); Assert.AreEqual(true, DataBinding, "AfterDataBinding"); ResetEvents(); Assert.AreEqual(false, ItemDataBounding, "BeforeItemDataBound"); SiteMapNodeItem i = new SiteMapNodeItem(0, SiteMapNodeItemType.Root); smp.DoOnItemDataBound(new SiteMapNodeItemEventArgs(i)); Assert.AreEqual(true, ItemDataBounding, "AfterItemDataBound"); ResetEvents(); SiteMapNodeItemEventArgs MyArgs = new SiteMapNodeItemEventArgs(new SiteMapNodeItem(0, SiteMapNodeItemType.Parent)); Assert.AreEqual(false, ItemCreated, "BeforeItemCreated"); smp.DoOnItemCteated(MyArgs); Assert.AreEqual(true, ItemCreated, "AfterItemCreated"); }
protected void SiteMapPath1_ItemCreated(object sender, SiteMapNodeItemEventArgs e) { if (e.Item.ItemType == SiteMapNodeItemType.Root || (e.Item.ItemType == SiteMapNodeItemType.PathSeparator && e.Item.ItemIndex == 1)) { e.Item.Visible = false; } }
void siteMapPath_ItemDataBound(object sender, SiteMapNodeItemEventArgs e) { if (e.Item.SiteMapNode != null) { e.Item.SiteMapNode.ReadOnly = false; e.Item.SiteMapNode.Url = string.Format("{0}?{1}", e.Item.SiteMapNode.Key, Request.QueryString); } }
protected virtual void OnItemDataBound(SiteMapNodeItemEventArgs e) { SiteMapNodeItemEventHandler handler = (SiteMapNodeItemEventHandler)base.Events[_eventItemDataBound]; if (handler != null) { handler(this, e); } }
protected void SiteMapPath_breadcrumb_ItemCreated(object sender, SiteMapNodeItemEventArgs e) { //hidding dummy root and pathseperator dynamically if (e.Item.ItemType == SiteMapNodeItemType.Root || e.Item.ItemType == SiteMapNodeItemType.PathSeparator && e.Item.ItemIndex == 1) { e.Item.Visible = false; } }
protected void SiteMapPath1_ItemCreated(object sender, SiteMapNodeItemEventArgs e) { //web.stemap file must be in root node to recognize the file //if ((e.Item.ItemType == SiteMapNodeItemType.Root) | (e.Item.ItemType == SiteMapNodeItemType.PathSeparator & e.Item.ItemIndex == 1)) //{ // e.Item.Visible = false; //} }
//void siteMapPath_ItemCreated(object sender, SiteMapNodeItemEventArgs e) //{ // if (e.Item.SiteMapNode.Url != null) // { // e.Item.SiteMapNode.Url. = string.Format("{0}?{1}", e.Item.SiteMapNode.Url, Request.QueryString); // } //} void siteMapPath_ItemDataBound(object sender, SiteMapNodeItemEventArgs e) { // SiteMap.Provider.CurrentNode.ReadOnly = false; if (e.Item.SiteMapNode != null) { // e.Item.SiteMapNode.ReadOnly = false; // e.Item.SiteMapNode.Url = string.Format("{0}?{1}", e.Item.SiteMapNode.Url, Request.QueryString); } }
protected void SiteMapPath_ItemCreated(object sender, SiteMapNodeItemEventArgs e) { if (e.Item.ItemType == SiteMapNodeItemType.Root) { SiteMapPath.PathSeparator = " "; } else { SiteMapPath.PathSeparator = " > "; } }
void breadCrumbsControl_ItemDataBound(object sender, SiteMapNodeItemEventArgs e) { if (enableUnclickableLinks) { mojoSiteMapNode mapNode = (mojoSiteMapNode)e.Item.SiteMapNode; if ((mapNode != null) && (!mapNode.IsClickable)) { e.Item.Enabled = false; } } }
protected virtual void OnItemDataBound(SiteMapNodeItemEventArgs e) { if (Events != null) { SiteMapNodeItemEventHandler eh = (SiteMapNodeItemEventHandler)Events [ItemDataBoundEvent]; if (eh != null) { eh(this, e); } } }
private void AddLiteralAfterCurrentNode(SiteMapNodeItem item) { if (item.SiteMapNode.ChildNodes != null) { SiteMapNodeItem item2 = new SiteMapNodeItem(item.ItemIndex, SiteMapNodeItemType.PathSeparator); SiteMapNodeItemEventArgs e = new SiteMapNodeItemEventArgs(item2); this.InitializeItem(item2); this.OnItemCreated(e); item.Controls.Add(item2); Literal child = new Literal { Mode = LiteralMode.PassThrough, Text = this.AdditionalNode }; item.Controls.Add(child); } }
//ItemCreated事件 protected void SiteMapPath1_ItemCreated(object sender, SiteMapNodeItemEventArgs e) { if (e.Item.ItemType.ToString() == SiteMapNodeItemType.Current.ToString()) { switch (e.Item.SiteMapNode.Description) { case "INTEL": txtMsg.Text = "買" + e.Item.SiteMapNode.Title + "就可進行國外旅遊抽獎"; break; case "AMD": txtMsg.Text = e.Item.SiteMapNode.Title + "正在進行降價25%大促銷"; break; } } }
//[Obsolete] //private void CreateControlHierarchyRecursive(ref int index, SiteMapNode node, int parentLevels) //{ // if (parentLevels != 0) // { // SiteMapNode parentNode = node.ParentNode; // if (parentNode != null) // { // this.CreateControlHierarchyRecursive(ref index, parentNode, parentLevels - 1); // this.CreateItem(index++, SiteMapNodeItemType.Parent, node); // } // else // { // this.CreateItem(index++, SiteMapNodeItemType.Root, node); // } // } //} private ResSiteMapNodeItem CreateItem(int itemIndex, Control container, SiteMapNodeItemType itemType, SiteMapNode node) { ResSiteMapNodeItem item = new ResSiteMapNodeItem(itemIndex, itemType); int index = -1; SiteMapNodeItemEventArgs e = new SiteMapNodeItemEventArgs(item); item.SiteMapNode = node; this.InitializeItem(item); this.OnItemCreated(e); container.Controls.AddAt(index, item); item.DataBind(); this.OnItemDataBound(e); item.SiteMapNode = null; item.EnableViewState = false; return(item); }
protected ResSiteMapNodeItem CreateItem(int itemIndex, SiteMapNodeItemType itemType, SiteMapNode node) { ResSiteMapNodeItem item = new ResSiteMapNodeItem(itemIndex, itemType); int index = (this.PathDirection == PathDirection.CurrentToRoot) ? 0 : -1; SiteMapNodeItemEventArgs e = new SiteMapNodeItemEventArgs(item); item.SiteMapNode = node; this.InitializeItem(item); this.OnItemCreated(e); this.Controls.AddAt(index, item); item.DataBind(); this.OnItemDataBound(e); item.SiteMapNode = null; item.EnableViewState = false; return(item); }
// </Snippet2> // <Snippet3> private void AddDropDownListAfterCurrentNode(SiteMapNodeItem item) { SiteMapNodeCollection childNodes = item.SiteMapNode.ChildNodes; // Only do this work if there are child nodes. if (childNodes != null) { // Add another PathSeparator after the CurrentNode. SiteMapNodeItem finalSeparator = new SiteMapNodeItem(item.ItemIndex, SiteMapNodeItemType.PathSeparator); SiteMapNodeItemEventArgs eventArgs = new SiteMapNodeItemEventArgs(finalSeparator); InitializeItem(finalSeparator); // Call OnItemCreated every time a SiteMapNodeItem is // created and initialized. OnItemCreated(eventArgs); // The pathSeparator does not bind to any SiteMapNode, so // do not call DataBind on the SiteMapNodeItem. item.Controls.Add(finalSeparator); // Create a DropDownList and populate it with the children of the // CurrentNode. There are no styles or templates that are applied // to the DropDownList control. If OnSelectedIndexChanged is raised, // the event handler redirects to the page selected. // The CurrentNode has child nodes. DropDownList ddList = new DropDownList(); ddList.AutoPostBack = true; ddList.SelectedIndexChanged += new EventHandler(this.DropDownNavPathEventHandler); // Add a ListItem to the DropDownList for every node in the // SiteMapNodes collection. foreach (SiteMapNode node in childNodes) { ddList.Items.Add(new ListItem(node.Title, node.Url)); } item.Controls.Add(ddList); } }
static void s_ItemCreated(object sender, SiteMapNodeItemEventArgs e) { if (WebTest.CurrentTest.UserData == null) { ArrayList list = new ArrayList(); list.Add("ItemCreated"); WebTest.CurrentTest.UserData = list; } else { ArrayList list = WebTest.CurrentTest.UserData as ArrayList; if (list == null) { throw new NullReferenceException(); } list.Add("ItemCreated"); WebTest.CurrentTest.UserData = list; } }
private SiteMapNodeItem CreateItemFromCmsPathNode(int itemIndex, SiteMapNodeItemType itemType, CmsPathNode pathNode) { SiteMapNodeItem item1 = new SiteMapNodeItem(itemIndex, itemType); int num1 = (this.PathDirection == PathDirection.CurrentToRoot) ? 0 : -1; SiteMapNodeItemEventArgs args1 = new SiteMapNodeItemEventArgs(item1); if (pathNode != null) { string nodeUrl = string.Empty; switch (pathNode.NodeType) { case CatalogNodeType.Category: nodeUrl = "Default.aspx?CategoryId=" + pathNode.NodeId; break; case CatalogNodeType.Product: nodeUrl = "../products/editproduct.aspx?ProductId=" + pathNode.NodeId; break; case CatalogNodeType.Webpage: nodeUrl = "../webpages/editwebpage.aspx?WebpageId=" + pathNode.NodeId; break; case CatalogNodeType.Link: nodeUrl = "viewlink.aspx?LinkId=" + pathNode.NodeId; break; } SiteMapNode mapNode = new SiteMapNode(new XmlSiteMapProvider(), pathNode.NodeId.ToString(), nodeUrl, pathNode.Title, pathNode.Description); item1.SiteMapNode = mapNode; } this.InitializeItem(item1); this.OnItemCreated(args1); this.Controls.AddAt(num1, item1); item1.DataBind(); this.OnItemDataBound(args1); item1.SiteMapNode = null; item1.EnableViewState = false; return(item1); }
protected void smp_ItemCreated(object sender, SiteMapNodeItemEventArgs e) { //if (e.Item.SiteMapNode != null) _title = e.Item.SiteMapNode.Title; }
public void DoOnItemCteated(SiteMapNodeItemEventArgs e) { base.OnItemCreated(e); }
public void DoOnItemDataBound(SiteMapNodeItemEventArgs e) { base.OnItemDataBound(e); }
protected override void OnItemCreated(SiteMapNodeItemEventArgs e) { base.OnItemCreated(e); if (e.Item.ItemType == SiteMapNodeItemType.Root) { if (e.Item.Controls[0] is Literal) { Literal literal = e.Item.Controls[0] as Literal; literal.Mode = LiteralMode.PassThrough; literal.Text = literal.Text.Replace("{SiteName}", SiteConfig.SiteInfo.SiteName); } else if (e.Item.Controls[0] is HyperLink) { HyperLink link = e.Item.Controls[0] as HyperLink; link.NavigateUrl = SiteConfig.SiteInfo.SiteUrl; link.ToolTip = link.ToolTip.Replace("{SiteName}", SiteConfig.SiteInfo.SiteName); link.Text = link.Text.Replace("{SiteName}", SiteConfig.SiteInfo.SiteName); } } if (e.Item.ItemType == SiteMapNodeItemType.Current) { this.tempNode = e.Item.SiteMapNode; if (e.Item.Controls[0] is Literal) { Literal literal2 = e.Item.Controls[0] as Literal; literal2.Mode = LiteralMode.PassThrough; literal2.Text = Regex.Replace(literal2.Text, @"\{\$[^}]+\}", new MatchEvaluator(this.UrlVarMatch)); literal2.Text = Regex.Replace(literal2.Text, @"\{\@[^}]+\}", new MatchEvaluator(this.UrlTypeMatch)); } else if (e.Item.Controls[0] is HyperLink) { HyperLink link2 = e.Item.Controls[0] as HyperLink; link2.NavigateUrl = null; link2.ToolTip = null; link2.Text = Regex.Replace(link2.Text, @"\{\$[^}]+\}", new MatchEvaluator(this.UrlVarMatch)); link2.Text = Regex.Replace(link2.Text, @"\{\@[^}]+\}", new MatchEvaluator(this.UrlTypeMatch)); link2.Text = HttpContext.Current.Server.HtmlDecode(link2.Text); } this.tempNode = null; } if (!string.IsNullOrEmpty(this.CurrentNode) && (e.Item.ItemType == SiteMapNodeItemType.Current)) { if (e.Item.Controls[0] is Literal) { Literal literal3 = e.Item.Controls[0] as Literal; literal3.Mode = LiteralMode.PassThrough; literal3.Text = this.CurrentNode; } else if (e.Item.Controls[0] is HyperLink) { HyperLink link3 = e.Item.Controls[0] as HyperLink; link3.NavigateUrl = null; link3.ToolTip = null; link3.Text = this.CurrentNode; } } if ((!string.IsNullOrEmpty(this.ParentNodeUrl) && (e.Item.ItemType == SiteMapNodeItemType.Parent)) && (e.Item.Controls[0] is HyperLink)) { HyperLink link4 = e.Item.Controls[0] as HyperLink; link4.NavigateUrl = this.ParentNodeUrl; } }
private void ItemCreatedHandler(object sender, SiteMapNodeItemEventArgs e) { ItemCreated = true; }
private void ItemDataBoundHandler(object sender, SiteMapNodeItemEventArgs e) { ItemDataBounding = true; }
protected virtual void CreateControlHierarchy() { if (!this.Visible) { return; } ArrayList nodes = new ArrayList(); SiteMapNode node = Provider.CurrentNode; if ((node == null) && (overrideCurrentNode != null)) { node = overrideCurrentNode; } if (node == null) { return; } int levels = ParentLevelsDisplayed != -1 ? ParentLevelsDisplayed + 1 : int.MaxValue; while (node != null && levels > 0) { if (nodes.Count > 0) { SiteMapNodeItem sep = new SiteMapNodeItem(nodes.Count, SiteMapNodeItemType.PathSeparator); InitializeItem(sep); SiteMapNodeItemEventArgs sargs = new SiteMapNodeItemEventArgs(sep); OnItemCreated(sargs); nodes.Add(sep); } SiteMapNodeItemType nt; if (nodes.Count == 0) { nt = SiteMapNodeItemType.Current; } else if (node.ParentNode == null) { nt = SiteMapNodeItemType.Root; } else { nt = SiteMapNodeItemType.Parent; } SiteMapNodeItem it = new SiteMapNodeItem(nodes.Count, nt); it.SiteMapNode = node; InitializeItem(it); SiteMapNodeItemEventArgs args = new SiteMapNodeItemEventArgs(it); OnItemCreated(args); nodes.Add(it); node = node.ParentNode; levels--; } if (PathDirection == PathDirection.RootToCurrent) { for (int n = nodes.Count - 1; n >= 0; n--) { Controls.Add((Control)nodes[n]); } } else { for (int n = 0; n < nodes.Count; n++) { Controls.Add((Control)nodes[n]); } } }