Skip to content

<xmod:AjaxButton>

<xmod:AjaxButton> renders a push-button that fires an AJAX request when clicked. The HTML returned by Url is dropped into the element matched by Target (a jQuery selector). No page postback.

Requires jQuery

The hosting page must include jQuery. Default DNN skins include it; verify a custom skin does too.

Sibling variants

Example

html
<xmod:Template Id="Employees">
  <ListDataSource CommandText="SELECT * FROM Employees" />
  <ItemTemplate>
    <strong>[[FirstName]] [[LastName]]</strong>
    <xmod:AjaxButton Text="Get Employee History"
        Url='[[Join("~/GetEmployeeHistory.aspx?empid={0}",[[EmployeeId]])]]'
        Target="#EmployeeHistory" />
  </ItemTemplate>
</xmod:Template>

<div id="EmployeeHistory"></div>

Properties

PropertyValuesDefaultDescription
Url *URLThe URL to fetch via AJAX
TargetjQuery selectorThe element whose content is replaced by the AJAX response. Required unless OnSuccess is set
TextstringCaption displayed on the button
LoadingImageUrlURLImage shown while the AJAX call is in flight. Tilde paths supported
LoadingCssClassstringCSS class applied to the loading image
OnSuccessJS function nameJavaScript function called with the response data instead of replacing Target's content
OnErrorJS function nameJavaScript function called with (jqXHR, textStatus, errorThrown) if the AJAX call fails
Methodget postgetHTTP method used for the request
CssClassstringCSS class name(s)
StylestringInline CSS
WidthsizeWidth of the button
HeightsizeHeight of the button
ToolTipstringHover tooltip
VisibleTrue FalseTrueShows or hides the button

* Required property

Deprecated Properties (styling)

BackColor, BorderColor, BorderStyle, BorderWidth, Font-*, ForeColor — use CssClass or Style instead.

Property Details

  • Url: The endpoint hit by the AJAX request. Tilde-prefixed paths are resolved through Page.ResolveUrl. The endpoint should return HTML — that's what gets dropped into the target. Use <xmod:Feed ContentType="text/html"> to expose XMP-driven HTML for AJAX consumption.

  • Target: A jQuery selector — typically #id for an element by ID. The response HTML replaces the element's existing content. Required unless OnSuccess is set (in which case your custom JS handles the response).

  • LoadingImageUrl: An image (typically a spinner GIF) shown immediately after the button is clicked, removed when the AJAX call returns. The image renders right after the button; if LoadingCssClass is set, those classes are applied to the <img>.

  • OnSuccess: A JavaScript function name (no parentheses). Overrides the default behavior of replacing Target's content. Your function receives the response data as its single argument:

    js
    function doSomethingCool(data) {
      // do something with data
    }
    html
    <xmod:AjaxButton Url="..." OnSuccess="doSomethingCool" />
  • OnError: A JavaScript function name (no parentheses) called if the AJAX call fails. Receives jQuery's (jqXHR, textStatus, errorThrown) arguments.