Alerting the error messages.

2 posts, 0 answers
  1. Ivy
    Ivy avatar
    30 posts
    Member since:
    Feb 2013

    Posted 23 Jul 2013 Link to this post

    Hi 

    There are few input fields and required field validators and I tried to display the error message inside the control which is not completely possible due to browser related issues. So I thought of alerting the error messages on validation failed. But how can I get the error messages in javascript so that I can display them in an alert box? Is this a possible requirement?

    Thanks
    Ivy
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 23 Jul 2013 Link to this post

    Hi Ivy,

    The ASP ValidationSummary has a ShowMessageBox property which you can set to true in order to achieve your requirement. If the ShowMessageBox property is set to true then all the Error Messages are displayed in a browser alert box. Please have a look into the sample code I tried which works fine at my end.

    ASPX:
    <telerik:RadTextBox ID="RadTextBoxFirstName" runat="server" EmptyMessage="First Name" />
    <br />
    <br />
    <telerik:RadTextBox ID="RadTextBoxLastName" runat="server" EmptyMessage="Last Name" />
    <br />
    <br />
    <telerik:RadTextBox ID="RadTextBoxEmailid" runat="server" EmptyMessage="Email-ID" /><br />
    <br />
    <telerik:RadButton ID="RadButton1" runat="server" Text="Send" CausesValidation="true"
        ValidationGroup="ValidationGroup1">
    </telerik:RadButton>
    <asp:RequiredFieldValidator ID="RequiredFirstName" runat="server" ErrorMessage="Full Name is mandatory!"
        ControlToValidate="RadTextBoxFirstName" Display="None" ValidationGroup="ValidationGroup1"></asp:RequiredFieldValidator>
    <asp:RequiredFieldValidator ID="RequiredLastname" runat="server" ErrorMessage="Last Name is mandatory!"
        ControlToValidate="RadTextBoxLastName" Display="None" ValidationGroup="ValidationGroup1"></asp:RequiredFieldValidator>
    <asp:RequiredFieldValidator ID="RequiredEmailid" runat="server" ErrorMessage="Email-ID is mandatory!"
        ControlToValidate="RadTextBoxEmailid" Display="None" ValidationGroup="ValidationGroup1"></asp:RequiredFieldValidator>
    <asp:ValidationSummary ID="ValidationSummary1" runat="server" ShowSummary="false"
        ShowMessageBox="true" HeaderText="Missing Fields" ValidationGroup="ValidationGroup1"
        DisplayMode="BulletList" />

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top