Return to the menu   Select another DES Module

Demonstrates using alert boxes to call attention to errors

Add a PageManager control to the page. Then use these properties to establish alerts:

  • ShowAlertOnChange – Show an alert after a validation error caused by an onchange event. The alert includes all the error messages associated with the field that was changed.
  • ShowAlertOnSubmit – Show an alert when the page is submitted and errors are found. The alert includes all of the error messages associated with the submit control’s validation group.
  • DelayAlertOnSubmitCount – When using ShowAlertOnSubmit, you can delay the alert from appearing until the user has attempted to submit several times. Use it when you normally wouldn’t show an alert because it helps the user when they click the submit button several times without noticing the errors that are preventing the page from being submitted.
  • ShowAlertAfterPostBackError – Show an alert when after server side validation detects an error. The alert appears as the page is reloaded, drawing the user's attention to a new error case.
  • AlertTemplate – Used in the alerts shown by the ShowAlertOnChange and ShowAlertOnSubmit properties. It provides a textual framework for building a single description from the list of error messages associated with the fields that have errors. If it is blank, you will get only a list of error messages. Otherwise, use the token “{0}” in this string. It will be replaced by the error messages.
  • AlertErrorLeadText – Used in the alerts shown by the ShowAlertOnChange and ShowAlertOnSubmit properties. This text is inserted before each error message. Use it to denote a new message. For example, "-" or "*". If you use a “#” symbol, that character will be replaced by a number that represents the error message's position in the list.
  • AlertErrorListStyle – Used in the alerts shown by the ShowAlertOnChange and ShowAlertOnSubmit properties. When true, error messages are listed on separate lines. When false, error messages are listed in a single paragraph style.
  • AlertShowsSummaryMessage – Used by the ShowAlertOnChange property to determine the source of the error message on a validator: from its ErrorMessage or SummaryErrorMessage property. When true, SummaryErrorMessage is used. When false or not assigned, ErrorMessage is used.

Controls

To show an error, click the button for the ShowAlertOnSubmit alert. The type 'abc' into the textbox and tab off for the ShowAlertOnChange alert.



Source Code (C#)

<script runat="server">
protected void Button1_Click(object sender, EventArgs e) { if (PeterBlum.DES.Globals.WebFormDirector.IsValid) { // save your data here } }
</script> To show an error, click the button for the <span class="PropertyName">ShowAlertOnSubmit</span> alert. The type 'abc' into the textbox and tab off for the <span class="PropertyName">ShowAlertOnChange</span> alert.<br/> <br/> <des:PageManager ID="PageManager1" runat="server" ShowAlertOnChange="True" ShowAlertOnSubmit="True" /> <asp:TextBox ID="TextBox1" runat="server" /> <des:RequiredTextValidator ID="RequiredTextValidator1" runat="server" ControlIDToEvaluate="TextBox1" ErrorMessage="Required" > <ErrorFormatterContainer> <des:TextErrorFormatter Display="Dynamic" /> </ErrorFormatterContainer> </des:RequiredTextValidator> <des:DataTypeCheckValidator ID="DTC1" runat="server" ControlIDToEvaluate="TextBox1" DataType="Integer" ErrorMessage="Illegal format. Only digits are allowed." /> <br/> <des:Button ID="Button1" runat="server" Text="Submit" />

Return to the menu   Select another DES Module