protected void AddRelations_Click(object sender, EventArgs e) { ErrorMessageContainer.Visible = false; if (!string.IsNullOrEmpty(NewPageTextBox.Text)) { if (Validate(CurrentRule, int.Parse(NewPageTextBox.Text), CurrentPage.PageLink.ID)) { AddRelation(CurrentRule.RuleName, int.Parse(NewPageTextBox.Text), CurrentPage.PageLink.ID); } else { ErrorMessageContainer.Visible = true; } NewPageTextBox.Text = string.Empty; } else { foreach (ListItem li in AllRelations.Items) { if (li.Selected) { if (Validate(CurrentRule, int.Parse(li.Value), CurrentPage.PageLink.ID)) { AddRelation(CurrentRule.RuleName, int.Parse(li.Value), CurrentPage.PageLink.ID); } else { ErrorMessageContainer.Visible = true; } } } } RelatedRelations.DataSource = GetRelationsForPage(CurrentPage.PageLink.ID, CurrentRule); RelatedRelations.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { ErrorMessageContainer.Visible = false; ScriptManager.GetCurrent(this.Page).RegisterAsyncPostBackControl(Button1); if (CurrentRule != null) { RuleName.Text = CurrentRule.RuleName; IsLeftRule = (CurrentRule.RuleDirection == Rule.Direction.Left); RuleDirectionLiteral.Text = _ruleDirection.ToString(); } else if (!string.IsNullOrEmpty(RuleName.Text)) { CurrentRule = RuleEngine.Instance.GetRule(RuleName.Text); _ruleDirection = (Rule.Direction)Enum.Parse(typeof(Rule.Direction), RuleDirectionLiteral.Text); } if (_ruleDirection == Rule.Direction.Both) { // Rule direction not set - check page against rule IsLeftRule = RuleEngine.Instance.IsLeftRule(CurrentPage.PageLink.ID, CurrentRule); } if (IsLeftRule && !CurrentRule.RuleVisibleLeft || !IsLeftRule && !CurrentRule.RuleVisibleRight) { this.Visible = false; return; } if (!IsPostBack) { PerformSearch_Click(null, null); } string pageTypes = ""; if (IsLeftRule) { pageTypes = HttpUtility.UrlDecode(CurrentRule.PageTypeRight); } else { pageTypes = HttpUtility.UrlDecode(CurrentRule.PageTypeLeft); } if (!IsPostBack) { if (pageTypes.Split(';').Length > 2) { PageTypesDropDown.DataSource = pageTypes.Split(';'); PageTypesDropDown.DataBind(); PageTypesContainer.Visible = true; PageTypesDropDown.SelectedIndex = PageTypesDropDown.Items.Count - 1; } } RelatedRelations.DataSource = GetRelationsForPage(CurrentPage.PageLink.ID, CurrentRule); RelatedRelations.DataBind(); }