/// <summary> /// Renders a command control as link with an icon, a text or both. /// </summary> /// <param name="renderingContext">The <see cref="BocColumnRenderingContext{BocColumnDefinition}"/>.</param> /// <param name="originalRowIndex">The zero-based index of the current row in <see cref="IBocList"/></param> /// <param name="businessObject">The <see cref="IBusinessObject"/> associated with the current row.</param> /// <param name="command">The <see cref="Remotion.ObjectBinding.Web.UI.Controls.BocList.RowEditModeCommand"/> that is issued /// when the control is clicked. Must not be <see langword="null" />.</param> /// <param name="alternateText">The <see cref="Remotion.ObjectBinding.Web.UI.Controls.BocList.ResourceIdentifier"/> /// specifying which resource to load as alternate text to the icon.</param> /// <param name="icon">The icon to render; must not be <see langword="null"/>. /// To skip the icon, set <see cref="IconInfo.Url"/> to <see langword="null" />.</param> /// <param name="text">The text to render after the icon. May be <see langword="null"/>, in which case no text is rendered.</param> protected virtual void RenderCommandControl( BocColumnRenderingContext <BocRowEditModeColumnDefinition> renderingContext, int originalRowIndex, IBusinessObject businessObject, BocList.RowEditModeCommand command, BocList.ResourceIdentifier alternateText, IconInfo icon, string text) { ArgumentUtility.CheckNotNull("renderingContext", renderingContext); ArgumentUtility.CheckNotNull("businessObject", businessObject); ArgumentUtility.CheckNotNull("icon", icon); if (!renderingContext.Control.IsReadOnly && renderingContext.Control.HasClientScript) { string argument = renderingContext.Control.GetRowEditCommandArgument(new BocListRow(originalRowIndex, businessObject), command); string postBackEvent = renderingContext.Control.Page.ClientScript.GetPostBackEventReference(renderingContext.Control, argument) + ";"; renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Href, "#"); renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Onclick, postBackEvent + c_onCommandClickScript); } var commandID = renderingContext.Control.ClientID + "_Column_" + renderingContext.ColumnIndex + "_RowEditCommand_" + command + "_Row_" + originalRowIndex; renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Id, commandID); renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.A); bool hasIcon = icon.HasRenderingInformation; bool hasText = !string.IsNullOrEmpty(text); if (hasIcon && hasText) { icon.Render(renderingContext.Writer, renderingContext.Control); renderingContext.Writer.Write(c_whiteSpace); } else if (hasIcon) { bool hasAlternateText = !string.IsNullOrEmpty(icon.AlternateText); if (!hasAlternateText) { icon.AlternateText = renderingContext.Control.GetResourceManager().GetString(alternateText); } icon.Render(renderingContext.Writer, renderingContext.Control); } if (hasText) { renderingContext.Writer.Write(text); // Do not HTML encode. } renderingContext.Writer.RenderEndTag(); }
/// <summary> /// Renders a command control as link with an icon, a text or both. /// </summary> /// <param name="renderingContext">The <see cref="BocColumnRenderingContext{BocColumnDefinition}"/>.</param> /// <param name="originalRowIndex">The zero-based index of the current row in <see cref="IBocList"/></param> /// <param name="businessObject">The <see cref="IBusinessObject"/> associated with the current row.</param> /// <param name="command">The <see cref="Remotion.ObjectBinding.Web.UI.Controls.BocList.RowEditModeCommand"/> that is issued /// when the control is clicked. Must not be <see langword="null" />.</param> /// <param name="alternateText">The <see cref="Remotion.ObjectBinding.Web.UI.Controls.BocList.ResourceIdentifier"/> /// specifying which resource to load as alternate text to the icon.</param> /// <param name="icon">The icon to render; must not be <see langword="null"/>. /// To skip the icon, set <see cref="IconInfo.Url"/> to <see langword="null" />.</param> /// <param name="text">The text to render after the icon. May be <see langword="null"/>, in which case no text is rendered.</param> protected virtual void RenderCommandControl( BocColumnRenderingContext <BocRowEditModeColumnDefinition> renderingContext, int originalRowIndex, IBusinessObject businessObject, BocList.RowEditModeCommand command, BocList.ResourceIdentifier alternateText, IconInfo icon, string text) { ArgumentUtility.CheckNotNull("renderingContext", renderingContext); ArgumentUtility.CheckNotNull("businessObject", businessObject); ArgumentUtility.CheckNotNull("icon", icon); string argument = renderingContext.Control.GetRowEditCommandArgument(new BocListRow(originalRowIndex, businessObject), command); string postBackEvent = renderingContext.Control.Page.ClientScript.GetPostBackEventReference(renderingContext.Control, argument) + ";"; var commandItemID = "Column_" + renderingContext.ColumnIndex + "_RowEditCommand_" + command + "_Row_" + originalRowIndex; Command c; if (!renderingContext.Control.IsReadOnly && renderingContext.Control.HasClientScript) { c = new Command(CommandType.Event) { EventCommand = new Command.EventCommandInfo() } } ; else { c = new Command(CommandType.None); } c.ItemID = commandItemID; c.OwnerControl = renderingContext.Control; c.RenderBegin(renderingContext.Writer, RenderingFeatures, postBackEvent, new string[0], c_onCommandClickScript, null); bool hasIcon = icon.HasRenderingInformation; bool hasText = !string.IsNullOrEmpty(text); if (hasIcon && hasText) { icon.Render(renderingContext.Writer, renderingContext.Control); renderingContext.Writer.Write(c_whiteSpace); } else if (hasIcon) { bool hasAlternateText = !string.IsNullOrEmpty(icon.AlternateText); if (!hasAlternateText) { icon.AlternateText = renderingContext.Control.GetResourceManager().GetString(alternateText); } icon.Render(renderingContext.Writer, renderingContext.Control); } if (hasText) { renderingContext.Writer.Write(text); // Do not HTML encode. } c.RenderEnd(renderingContext.Writer); }