private void AddError(String errMessage) { Label lblError = new Label(); lblError.ID = "lblError" + encryptingSupport.GetUniqueKey(); lblError.Text = errMessage; lblError.CssClass = CSSStrings.ErrorLabelCssClass; GetErrorsPanel().Controls.Add(lblError); LiteralControl br = new LiteralControl("<BR>"); GetErrorsPanel().Controls.Add(br); }
private void AddItemsToMenu(XPathNavigator xmlNavigator, string parentValue, string cssClass) { levelCount++; //check to see if the number of levels is not over the maximum if (levelCount > ApplicationConstants.REPORTING_MAXIMUM_LEVEL) { throw new XmlException(string.Format("A maximum of '{0}' menu levels is permitted. Level {1} is beyond this limit.", ApplicationConstants.REPORTING_MAXIMUM_LEVEL, xmlNavigator.GetAttribute("Text", ""))); } string navigatorText = xmlNavigator.GetAttribute("Text", ""); //check not to allow nodes without Text attribute if (string.IsNullOrEmpty(navigatorText)) { throw new XmlException("Text attribute cannot be empty."); } //on level 2 we should have only nodes if (levelCount == 2 && !string.IsNullOrEmpty(xmlNavigator.GetAttribute("NavigateUrl", ""))) { throw new XmlException(string.Format("Node '{0}' must be a parent MenuItem because it is a level 2 node.", navigatorText)); } //Check not to allow leaf not to have a NavigateUrl attribute. Except level 2. if (levelCount > 2 && !xmlNavigator.HasChildren && string.IsNullOrEmpty(xmlNavigator.GetAttribute("NavigateUrl", ""))) { throw new XmlException(string.Format("NavigateUrl attribute is empty for node '{0}'. This is not allowed for a leaf MenuItem.", navigatorText)); } //Navigate url must be empty for a parent MenuItems. if (xmlNavigator.HasChildren && !string.IsNullOrEmpty(xmlNavigator.GetAttribute("NavigateUrl", ""))) { throw new XmlException(string.Format("NavigateUrl attribute is NOT empty for node '{0}'. This is not allowed for a parent MenuItem.", navigatorText)); } //Window must be empty for a parent MenuItems. if (xmlNavigator.HasChildren && !string.IsNullOrEmpty(xmlNavigator.GetAttribute("Window", ""))) { throw new XmlException(string.Format("Window attribute is NOT empty for node '{0}'. This is not allowed for a parent MenuItem.", navigatorText)); } //********* make the breadcrumb************************ repBreadCrumb += " > " + navigatorText; //***************************************************** EncryptingSupport encryptingSupport = new EncryptingSupport(); IndMenuItem itemToAdd = new IndMenuItem(); string newValue = encryptingSupport.GetUniqueKey(); itemToAdd.Value = newValue; itemToAdd.Text = navigatorText; String window = xmlNavigator.GetAttribute("Window", ""); String urlType = xmlNavigator.GetAttribute("UrlType", ""); String navigateUrl = xmlNavigator.GetAttribute("NavigateUrl", ""); if (window == "new") { itemToAdd.Target = "newINDev3Window"; } String navigateUrlToSet; if (!string.IsNullOrEmpty(navigateUrl)) { if (urlType == "absolute") { navigateUrlToSet = navigateUrl; } else { //we remove any HTTP text to avoid some fatal error navigateUrl = navigateUrl.Replace("http://", ""); navigateUrlToSet = "~/ReportPlaceHolder.aspx?Code=" + navigateUrl + "&nav=" + repBreadCrumb; } itemToAdd.NavigateUrl = Server.UrlDecode(navigateUrlToSet); } itemToAdd.CssClass = cssClass; //Add to menu RadMenuItem item = mnuMain.FindItemByValue(parentValue); item.Items.Add(itemToAdd); //if has children append this function again XPathNodeIterator NodeItererator = xmlNavigator.Select("MenuItem"); int iterator = 0; while (NodeItererator.MoveNext()) { string css = getCssClass(NodeItererator.Count, iterator); AddItemsToMenu(NodeItererator.Current, newValue, css); iterator++; levelCount--; //***********reset the breadcrumb because navigator enters another branch ************* repBreadCrumb = repBreadCrumb.Remove(repBreadCrumb.LastIndexOf(" > ")); //************************************************************************************* } }