Skip to main content
All docs
V23.2

AlertControl.RaiseHtmlElementClick(String, AlertHtmlPopup) Method

Emulates user click on the given HTML element.

Namespace: DevExpress.XtraBars.Alerter

Assembly: DevExpress.XtraBars.v23.2.dll

NuGet Package: DevExpress.Win.Navigation

Declaration

public void RaiseHtmlElementClick(
    string elementId,
    AlertHtmlPopup popup
)

Parameters

Name Type Description
elementId String

The ID of an element whose click event should be raised.

popup DevExpress.XtraBars.Alerter.AlertHtmlPopup

The alert that owns the element with the given ID.

Remarks

The following code shows three alerts that use the same HTML template, but retrieve data from different data objects:

<!-- ... -->
<div class="captionText">${Title}</div>
<div class="subText">${Subtitle}</div>
<div class="regularText">${MessageText}</div>
<div id="okButton" class="ok-button">OK</div>
<!-- ... -->
AlertData aData1 = new AlertData("Notification", "Subtitle string", "Alert #1");
AlertData aData2 = new AlertData("Notification", "Subtitle string", "Alert #2");
AlertData aData3 = new AlertData("Notification", "Subtitle string", "Alert #3");
alertControl1.Show(aData1, this);
alertControl1.Show(aData2, this);
alertControl1.Show(aData3, this);

// Data for alerts
public class AlertData {

    public AlertData(string title, string subtitle, string messageText) {
        Title = title;
        Subtitle = subtitle;
        MessageText = messageText;
    }

    public string Title { get; set; }
    public string Subtitle { get; set; }
    public string MessageText { get; set; }
}

To trigger an onClick function associated with an element of a specific notification, you need to call the RaiseHtmlElementClick method with two parameters:

  • The unique element ID, which is set in the HTML markup.
  • The specific alert instance. All active HTML-designed alerts are stored in the HtmlPopupList collection. You can browse it to find the required notification.

The code below finds the notification that has "#2" in its "MessageText" string, and emulates user clicking the OK button of this notification.

AlertHtmlPopup target = alertControl1.HtmlPopupList.Find(x =>
    (x.DataContext as AlertData).MessageText.Contains("#2"));
alertControl1.RaiseHtmlElementClick("okButton", target);
See Also