Back to Devexpress

ASPxValidationSummary.ShowErrorAsLink Property

aspnet-devexpress-dot-web-dot-aspxvalidationsummary-a419d9c6.md

latest4.9 KB
Original Source

ASPxValidationSummary.ShowErrorAsLink Property

Gets or sets whether the errors should be displayed within an editor as links.

Namespace : DevExpress.Web

Assembly : DevExpress.Web.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
[DefaultValue(true)]
public bool ShowErrorAsLink { get; set; }
vb
<DefaultValue(True)>
Public Property ShowErrorAsLink As Boolean

Property Value

TypeDefaultDescription
Booleantrue

true if the errors are displayed as hyperlinks; otherwise, false.

|

Remarks

The ASPxValidationSummary represent a block for displaying the list of errors of the validated editors on the form.

If the ShowErrorAsLink property is set to true, the errors are displayed as hyperinks that when clicked, move focus to the corresponding editor.

Example

The following section of the Validation Summary online demo illustrates how to customize the settings of the ASPxValidationSummary control.

This settings are specified within a panel by using the ASPxRadioButtonList, ASPxCheckBox editors.

csharp
protected void Page_Load(object sender, EventArgs e) {
    ApplyValidationSummarySettings();
    ApplyEditorsSettings();
    if(!IsPostBack && !IsCallback)
        ASPxEdit.ValidateEditorsInContainer(this);
}

private void ApplyValidationSummarySettings() {
    vsValidationSummary1.RenderMode = (ValidationSummaryRenderMode)Enum.Parse(typeof
        (ValidationSummaryRenderMode), rblRenderMode.SelectedItem.Value.ToString());
    vsValidationSummary1.ShowErrorAsLink = chbShowErrorAsLink.Checked;
}

private void ApplyEditorsSettings() {
    ASPxEdit[] editors = new ASPxEdit[] { tbName, tbEmail };
    foreach(ASPxEdit editor in editors) {
        editor.ValidationSettings.ValidateOnLeave = chbValidateOnLeave.Checked;
        editor.ValidationSettings.SetFocusOnError = chbSetFocusOnError.Checked;
    }
}
javascript
function ShowHideVS(s, e) {
    if (e.visible)
        document.getElementById("errorsContainer").style.display = "block";
    else
        document.getElementById("errorsContainer").style.display = "none";
}
aspx
<!-- DevExpress Editors for validation -->

<dx:ASPxTextBox ID="tbName" runat="server" Width="200px">
    <ValidationSettings>
        <RequiredField IsRequired="True" ErrorText="Name is required" />
        <RegularExpression ValidationExpression=".{2,}" ErrorText="Name should contain at least two letters" />
    </ValidationSettings>
</dx:ASPxTextBox>

<dx:ASPxTextBox ID="tbEmail" runat="server" Width="200px">
    <ValidationSettings>
        <RequiredField IsRequired="True" ErrorText="E-mail is required" />
        <RegularExpression ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" 
            ErrorText="Invalid e-mail" />
    </ValidationSettings>
</dx:ASPxTextBox>

<!-- ASPxValidationSummary -->

<dx:ASPxValidationSummary ID="vsValidationSummary1" runat="server" 
RenderMode="BulletedList" Width="243px" Paddings-PaddingLeft="14px" ClientInstanceName="validationSummary">
    <ClientSideEvents VisibilityChanged="ShowHideVS" />
</dx:ASPxValidationSummary>

<!-- Panel with settings for the ASPxValidationSummary -->

<dx:ASPxRadioButtonList ID="rblRenderMode" runat="server" SelectedIndex="0" AutoPostBack="True" RepeatDirection="Horizontal">
    <Paddings Padding="0" />
    <Border BorderStyle="None" />
    <Items>
        <dx:ListEditItem Value="BulletedList" />
        <dx:ListEditItem Value="OrderedList" />
        <dx:ListEditItem Value="Table" />
    </Items>
</dx:ASPxRadioButtonList>

<dx:ASPxCheckBox ID="chbShowErrorAsLink" runat="server" AutoPostBack="True" Checked="True" />

<dx:ASPxCheckBox ID="chbValidateOnLeave" runat="server" AutoPostBack="True" Checked="True" />

<dx:ASPxCheckBox ID="chbSetFocusOnError" runat="server" AutoPostBack="True" />

See Also

ValidationGroup

Validation Summary

ASPxValidationSummary Class

ASPxValidationSummary Members

DevExpress.Web Namespace