This is a migrated thread and some comments may be shown as answers.

Validation Summary in Notification

3 Answers 285 Views
Notification
This is a migrated thread and some comments may be shown as answers.
Duncan
Top achievements
Rank 2
Duncan asked on 18 Nov 2011, 07:54 PM
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

3 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 21 Nov 2011, 08:03 AM
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.
0
Duncan
Top achievements
Rank 2
answered on 08 Dec 2011, 05:08 PM
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>
0
Duncan
Top achievements
Rank 2
answered on 08 Dec 2011, 05:11 PM
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);
    }
}
Tags
Notification
Asked by
Duncan
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Duncan
Top achievements
Rank 2
Share this question
or