Validation Summary in Notification

4 posts, 1 answers
  1. Duncan
    Duncan avatar
    93 posts
    Member since:
    Jul 2012

    Posted 18 Nov 2011 Link to this post

    Hey guys, i wonder if someone would be kind enough to help me get the <asp:ValidationSummary> inside the notification box. Specifically the validation summary when client side validation is done, like the <asp:RequiredFieldValidator> or <asp:CompareValidator>. I have already successfully accomplished this scenario on the server side with the <asp:CustomValidator>... Any help with the client side functionality of this would be great!

    Thanks,

    Duncan
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 21 Nov 2011 Link to this post

    Hello Duncan,

    I am not quite sure about where you are attaching the event. Check the following forum thread which discussed similar scenario.
    Validation summary client side

    -Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Duncan
    Duncan avatar
    93 posts
    Member since:
    Jul 2012

    Posted 08 Dec 2011 Link to this post

    Thanks Princy,

    That is exactly the behavior i am looking to have, however i am trying to fire it from a ImageButton's OnClientClick event. And i just can't seem to get the thing to fire. I am not very good with Javascript so there is probably issue with my code. This is what i have, maybe you can point out my error:

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Notification_ValidationSummary.aspx.cs"
        Inherits="Notification_ValidationSummary" %>
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <asp:ScriptManager ID="Scriptmanager1" runat="server" />
        <asp:TextBox ID="firstName" runat="server" ValidationGroup="Group1" />
        <asp:RequiredFieldValidator ID="rfvFirstName" runat="server" ControlToValidate="firstName"
            Text="*" ErrorMessage="Please, fill in your first name!" ValidationGroup="Group1">
        </asp:RequiredFieldValidator>
        <asp:Button ID="btnValidate" runat="server" Text="Button" OnClientClick="OnLoginClick();" ValidationGroup="Group1" />
        <telerik:radnotification id="RadNotification1" runat="server" width="300" animation="Slide"
            enableroundedcorners="true" enableshadow="true" loadcontenton="PageLoad" title="Validation errors"
            offsetx="-20" offsety="-20" titleicon="warning" autoclosedelay="7000">
            <ContentTemplate>
                <asp:Label ID="Label1" Text="Errors from the form in Tab 1" runat="server" />
                <br />
              <asp:ValidationSummary ID="ValidationSummary1" runat="server" ValidationGroup="Group1" />
            </ContentTemplate>
          </telerik:radnotification>
        <script type="text/javascript">
     
            function OnLoginClick(sender, args) {
                var valid = Page_ClientValidate("Group1");
                if (!valid) {
                    args.set_cancel(true);
                    $find("<%=RadNotification1.ClientID %>").show();
                }
                else {
                    setTimeout(function () {
                        $find("<%=RadNotification1.ClientID %>").hide()
                    }, 0);
                }
            }
     
            function checkForValidPage(button) {
                var valid = Page_ClientValidate();
                if (!valid) {
                    $find("<%=RadNotification1.ClientID %>").show();
                }
                else {
                    __doPostBack(button.name, "");
                }
            }
        </script>
        </form>
    </body>
    </html>
  5. Duncan
    Duncan avatar
    93 posts
    Member since:
    Jul 2012

    Posted 08 Dec 2011 Link to this post

    I managed to get it functioning, there was a error in my OnLoginClick function:

    function OnLoginClick() {
        var valid = Page_ClientValidate("Group1");
        if (!valid) {
            $find("<%=RadNotification1.ClientID %>").show();
        }
        else {
            setTimeout(function () {
                $find("<%=RadNotification1.ClientID %>").hide()
            }, 0);
        }
    }
Back to Top