Validation Summary in rad window

7 posts, 0 answers
  1. DK
    DK avatar
    72 posts
    Member since:
    Jun 2009

    Posted 13 Aug 2009 Link to this post

    is there any way to show validation summary in radwindow or rad alert?
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 13 Aug 2009 Link to this post

    Hello,

    Try the following approach in order to show the RadAlert if the page is not validated.

    ASPX:
    <asp:TextBox ID="txt_name" runat="server" />  
    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="txt_name" ErrorMessage="Name" Text="*" runat="server"/>  
      
    <asp:ValidationSummary ID="ValidationSummary1" HeaderText="You must enter a value in the following fields:"  
        DisplayMode="BulletList" runat="server" EnableClientScript="false"  />  
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server"
    </telerik:RadWindowManager> 
      
    <asp:Button ID="b1" Text="Submit" runat="server" onmouseup="ShowAlert();" /> 

    JavaScript:
     
    <script type="text/javascript"
    function ShowAlert() 
        Page_ClientValidate(); 
        if(!Page_IsValid) 
            radalert('Enter the required details..'); 
    </script> 

    -Shinu.
  3. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 13 Aug 2009 Link to this post

    That's not showing the validation summary in a RadWindow though, is it? That's just saying "sort yourself out".
  4. DK
    DK avatar
    72 posts
    Member since:
    Jun 2009

    Posted 13 Aug 2009 Link to this post

    I got the solution to this problem
    i am using the following code.
    try it it is working fine for me.
    but the problem is that if you want to display bulleted list of summary then you cant.
    and besides this everything is working fine.


    <
    asp:TextBox ID="txt_name" runat="server" />  
    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="txt_name" ErrorMessage="Name" Text="*" runat="server"/>  
      <div id="divSummary">
    <asp:ValidationSummary ID="ValidationSummary1" HeaderText="You must enter a value in the following fields:"  
        DisplayMode="BulletList" runat="server" EnableClientScript="false"  validationgroup="reqFields" />  
    </div>
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server"
    </telerik:RadWindowManager> 
      
    <asp:Button ID="b1" Text="Submit" runat="server" onmouseup="ShowAlert();" /> 


    <script type="text/javascript"
    function ShowAlert() 

    var valGroup=    Page_ClientValidate("reqFields"); 
    var summary = document.findElementbyId('divSummary').innerHTML;
        if(!valGroup) 
            radalert(summary'); 
    </script> 
  5. Bob
    Bob avatar
    1 posts
    Member since:
    Oct 2007

    Posted 14 Aug 2009 Link to this post

    Aside from the popup with an alert icon and the OK button, the radwindow provides nothing to the user. 
    I had to change the javascript as below to get this to function:

     
    <script type="text/javascript"> 
        function ShowAlert() { 
        var valGroup = Page_ClientValidate("reqFields"); 
        var summary = document.getElementById('divSummary'); 
        if(valGroup) 
            radalert(summary.innerHTML); 
        }
    </script>

     

     

     

  6. Fiko
    Admin
    Fiko avatar
    1406 posts

    Posted 14 Aug 2009 Link to this post

    Hello Bob,

    I have already answered your support ticket.

    Best wishes,
    Fiko
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  7. Doug Beard
    Doug Beard avatar
    55 posts
    Member since:
    Sep 2009

    Posted 23 Sep 2009 Link to this post

    Here's how I did it.

    Place ValidationSummary on page as follows
    <div id="divSummary"
     
            <asp:ValidationSummary ID="ValidationSummary1" HeaderText="There are errors on the page:" 
     
                DisplayMode="BulletList" runat="server" ValidationGroup="reqFields" /> 
     
        </div> 
     

    Attach script function to postback control

    <asp:Button ID="btnAdd" runat="server" Enabled="false" Text="Add" onmouseup="ShowAlert();" 
     
                            OnClick="btnAdd_Click" /> 

     

    Now the script function
    function ShowAlert() { 
     
            //Grab the Validation Group 
     
            var valGroup = Page_ClientValidate("reqFields"); 
     
            //grab the ValidationSummary Control 
     
            var objValidationSummary = document.getElementById("ValidationSummary1") 
     
            //slurp up the ValidationSummary Control's content and format as desired 
     
            var sValidationSummaryHTML = '<font color=\"red\">' + objValidationSummary.innerHTML + '</font>
     
            //Make sure to hide the ValidationSummary control since we'll display RadWindow instead 
     
            objValidationSummary.style.visibility = "hidden" 
     
            //If not IsValid on group, pop window and prevent postback 
     
            if (!valGroup) { 
     
                radalert(sValidationSummaryHTML, 450, 210); 
     
                return false; 
     
            } 
     
        }  

Back to Top