Skip to content

<xmod:DeleteButton>

<xmod:DeleteButton> renders a push-button that runs the parent template's <DeleteCommand> for the current row. The supplied <Parameter> tags fill the command's parameters so the right record gets deleted.

This tag is gated by the parent template's DeleteRoles. Place it inside <ItemTemplate> or <AlternatingItemTemplate> so each row has its own button. Always pair it with an OnClientClick confirmation prompt — once the SQL runs, the deletion is permanent.

Sibling variants

Example

html
<xmod:Template Id="Employees">
  <ListDataSource CommandText="SELECT * FROM Employees" />
  <DeleteCommand CommandText="DELETE FROM Employees WHERE EmployeeId = @EmpID">
    <Parameter Name="EmployeeId" Alias="EmpID" />
  </DeleteCommand>

  <ItemTemplate>
    <strong>[[FirstName]] [[LastName]]</strong>
    <xmod:DeleteButton Text="Delete"
        OnClientClick="return confirm('Are you sure you want to delete this employee?');">
      <Parameter Name="EmployeeId" Alias="EmpID" Value="[[EmployeeId]]" DataType="Int32" />
    </xmod:DeleteButton>
  </ItemTemplate>
</xmod:Template>

Properties

PropertyValuesDefaultDescription
IDstringUnique identifier for the button
TextstringCaption displayed on the button
AjaxTrue FalseFalseWhen True, the delete runs via async postback (the row removes from the list without a full page refresh). Requires ID set (since v2.6)
CssClassstringCSS class name(s)
StylestringInline CSS
WidthsizeWidth of the button
HeightsizeHeight of the button
ToolTipstringHover tooltip
VisibleTrue FalseTrueShows or hides the button
OnClientClickJavaScriptClient-side script to run on click. Returning false cancels the delete — typically used for confirm() prompts
AccessKeystringKeyboard shortcut character
EnabledTrue FalseTrueWhen False, the button is disabled
TabIndexintegerTab order for keyboard navigation
Deprecated Properties (styling)
PropertyDescription
BackColor / BorderColor / BorderStyle / BorderWidthUse CssClass or Style instead
Font-Bold / Font-Italic / Font-Names / Font-Overline / Font-Size / Font-Strikeout / Font-UnderlineUse CssClass instead
ForeColorUse CssClass or Style instead

Child Tags

TagRequiredDescription
<Parameter>required (one per <DeleteCommand> parameter)Supplies the value for the matching <DeleteCommand> parameter

<Parameter>

Use one <Parameter> for each @param in the parent template's <DeleteCommand>. The values are typically field tokens that identify the row.

AttributeValuesDefaultDescription
Name *stringParameter name on this control
Aliasstring(same as Name)Alternate parameter name used in the SQL — useful when the data column has a name that conflicts with another parameter
Valuestring | tokenParameter value. Field tokens like [[ID]] are typical
DataTypedatabase typeStringData type used when binding

Property Details

  • Ajax: When True, the delete is executed via async postback. The list re-renders without the deleted row and the rest of the page stays put. The button must have its ID property set; the parent <xmod:Template> should also have Ajax="True".

  • OnClientClick: A JavaScript expression run when the button is clicked, before the delete posts back. Returning false cancels the delete. The standard pattern is a confirm dialog:

    html
    OnClientClick="return confirm('Delete this record?');"

    Without the return, the dialog still appears but the user's choice is ignored — the delete will proceed regardless.