protected override void Render(HtmlTextWriter writer) { // render nothing if the action does not exist if (Action == null) { return; } var actionClickable = true; if (CheckActionCount) { var am = ActionMenu.FindContainerActionMenu(this); List <ActionBase> scActions = null; var scenario = string.Empty; if (am != null) { scenario = am.Scenario; if (!string.IsNullOrEmpty(scenario)) { scActions = ActionFramework.GetActions(Content.Load(ContextPath), scenario, am.GetReplacedScenarioParameters()).ToList(); } } if (scActions != null) { if (scActions.Count > 1) { actionClickable = false; } else if (scActions.Count == 1 && string.Equals(scenario, "new", StringComparison.CurrentCultureIgnoreCase) && string.Equals(this.ActionName, "add", StringComparison.CurrentCultureIgnoreCase)) { // change action to the single "New" action found in the parent menu _action = scActions.First(); _actionChecked = true; this.Text = this.Text + " " + _action.Text; } } } if (actionClickable) { var claction = Action as ClientAction; if (claction != null && claction.Callback != null) { NavigateUrl = "javascript:"; this.Attributes["onclick"] = claction.Callback; } else { NavigateUrl = Action.Uri; } } // load html template (provided by the builder) string templateText = null; if (!string.IsNullOrEmpty(Template)) { templateText = HtmlTemplate.GetActionLinkTemplate(Template); } // load html template (by default names) if (string.IsNullOrEmpty(templateText)) { templateText = IconVisible ? (string.IsNullOrEmpty(IconUrl) ? HtmlTemplate.GetActionLinkTemplate(HtmlTemplate.Names.ActionButton) // icon is rendered as a <span> : HtmlTemplate.GetActionLinkTemplate(HtmlTemplate.Names.ActionImageButton)) // icon is rendered as an <image> tag : HtmlTemplate.GetActionLinkTemplate(HtmlTemplate.Names.ActionLink); // no icon } // add actionlinkbutton class only if there is no template if (string.IsNullOrEmpty(templateText)) { this.CssClass += " sn-actionlinkbutton"; } // fill control properties according to the current state of the action FillProperties(); // if a template was found, fill its parameters and render it if (!string.IsNullOrEmpty(templateText)) { writer.Write(TemplateManager.Replace(typeof(ActionTemplateReplacer), templateText, this)); return; } // backward compatibility (classic ASP.NET behavior, when there is no html template) base.Render(writer); }
protected override void Render(HtmlTextWriter writer) { //render nothing if the action does not exist if (Action == null) { return; } var actionClickable = true; if (CheckActionCount) { var am = ActionMenu.FindContainerActionMenu(this); List <ActionBase> scActions = null; var scenario = string.Empty; if (am != null) { scenario = am.Scenario; if (!string.IsNullOrEmpty(scenario)) { scActions = ActionFramework.GetActions(Content.Load(ContextPath), scenario, am.GetReplacedScenarioParameters()).ToList(); } } if (scActions != null) { if (scActions.Count > 1) { actionClickable = false; } else if (scActions.Count == 1 && string.Equals(scenario, "new", StringComparison.CurrentCultureIgnoreCase) && string.Equals(this.ActionName, "add", StringComparison.CurrentCultureIgnoreCase)) { //change action to the single "New" action found in the parent menu _action = scActions.First(); _actionChecked = true; this.Text = this.Text + " " + _action.Text; } } } if (actionClickable) { var claction = Action as ClientAction; if (claction != null && claction.Callback != null) { NavigateUrl = "javascript:"; this.Attributes["onclick"] = claction.Callback; } else { NavigateUrl = Action.Uri; } } this.CssClass += (string.IsNullOrEmpty(this.CssClass) ? "" : " ") + "sn-actionlinkbutton"; if (Action.Forbidden) { this.CssClass += " sn-disabled"; this.Enabled = false; this.NavigateUrl = string.Empty; } base.Render(writer); }