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

Using a ValidationSummar in a RadToolTip

4 Answers 85 Views
ToolTip
This is a migrated thread and some comments may be shown as answers.
Bernard
Top achievements
Rank 1
Bernard asked on 23 Mar 2011, 10:08 AM
Hello,
I would like to use a RadToolTip to add, modify items from a RadGrid.
It works well but when I add to the radtooltip a RequiredFieldValidator and ValidationSummary, the radtooltip doesn't work.

Could you help me ?

Here are the javascript an HTML:

<

 

telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">

 

 

    <script type="text/javascript">

 

        function

 

CloseToolTip()

 

 

        {

 

 

            var tooltip = Telerik.Web.UI.RadToolTip.getCurrent();

 

 

 

            if(tooltip)

 

 

                { tooltip.hide(); };

 

        }

        function

 

OkToolTip()

 

 

        {

 

            CloseToolTip();

 

            ajaxManager.ajaxRequest(

"RT_LOT");

 

 

        }

    </

 

script>

 

</

 

telerik:RadCodeBlock>

 


<

 

telerik:RadToolTip ID="RT_LOT" runat="server" HideEvent="FromCode" Modal="True"

 

 

Position="Center" RelativeTo="BrowserWindow" ShowCallout="False">

 

 

<br />

 

 

    <table style="border-color: #0000FF; border-width: 10px; width: 100%; text-align: left;">

 

 

        <tr>

 

 

            <td><asp:Label ID="RT_LOT_LibLabel" runat="server"></asp:Label></td>
            <td><asp:RequiredFieldValidator ID="RT_LOT_RFV" runat="server" Display="Dynamic" ErrorMessage="Erreur"

 

 

ControlToValidate="RT_LOT_Lib" SetFocusOnError="True">*</asp:RequiredFieldValidator></td>

 

 

            <td><asp:TextBox ID="RT_LOT_Lib" runat="server" Width="336px"></asp:TextBox></td>

 

 

        </tr>

 

 

        <tr>

 

 

            <td colspan="3"><asp:ValidationSummary ID="RT_LOT_ValidationSummary" DisplayMode="BulletList" runat="server" /></td>

 

 

        </tr>

 

 

        <tr>

 

 

            <td><input id="RT_LOT_Ok" runat="server" type="button" value="Ok" onclick="OkToolTip();"

 

 

                style="width: 80px; color: #008000; font-weight: bold;" /></td>

 

 

            <td></td>

 

 

            <td><input id="RT_LOT_AnnBt" type="button" value="Annuler" onclick="CloseToolTip();"

 

 

style="width: 80px; color: #FF0000; font-weight: bold;" /></td>

 

 

        </tr>

 

 

    </table>

 

 

</telerik:RadToolTip>

 


Here is the code behind:
// Ajaxifying

protected

 

void Page_Load(object sender, EventArgs e)

 

 

{

 

 

    try

 

    {
        

radAjaxManager.AjaxRequest += new RadAjaxControl.AjaxRequestDelegate(manager_AjaxRequest);

 

        radAjaxManager.AjaxSettings.AddAjaxSetting(toolBar, RT_LOT);
    }

 

    catch (Exception err)

 

 

    {...

}

 

 

}


// open the RadToolTip from a toolbar:

protected

 

void toolBar_ButtonClick(object sender, RadToolBarEventArgs e)

 

 

{

 

 

    try

 

    {

 

        switch (e.Item.Value)

 

 

        {

 

 

            case @"CRT":
                ...

 

                RT_LOT.Show();

 

                break;

 

        }

    }

 

    catch (Exception err)

 

 

        {...

}

 

}
// get the data from the RadToolTip

protected

 

void manager_AjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e)

 

 

{

 

 

    try

 

    {

 

        if (e.Argument == @"RT_LOT")

 

 

        {

 ... };

 

 

    }

 

 

    catch (Exception err)

 

 

        { ...

}

 

 

}


Many thanks...
Bernard

4 Answers, 1 is accepted

Sort by
0
Svetlina Anati
Telerik team
answered on 25 Mar 2011, 12:28 PM
Hello Bernard,

 I built a sample demo based on your code but unfortunately to no avail - I could not understand the scenario and the problem. Please, download the attached code and modify it accordingly but keep it still fully runnable. Once you do this, share fully working reproduction code along with detailed explanations of the exact expected and actual result and what you want to achieve and I will do my best to help.

Best wishes,
Svetlina
the Telerik team
0
Bernard
Top achievements
Rank 1
answered on 25 Mar 2011, 03:11 PM
Hello Svetlina,

Thanks for your answer and I'm sorry to be not enough accurate.
So I have followed your advice and there is a runnable example.

Actually, I would to take advantage of RequiredFieldValidator and ValidationSummary inside a RadToolTip !

I hope It's clearer for you.

Best regards,
Bernard

Html:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MainPage.aspx.cs" Inherits="Xarc.MainPage" %>
<%@ Register Assembly="Telerik.Web.UI, Version=2010.3.1317.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4"
    Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Page sans titre</title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="scriptManager" runat="server" AsyncPostBackTimeout="120" />
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">

        <script type="text/javascript">
            var ajaxManager;
            var aVs;
            function pageLoad()
            {
                ajaxManager = $find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>");
                aVs = $get("<%=RT_LOT_VS.ClientID %>");
            }
            function CloseToolTip() {

                var tooltip = Telerik.Web.UI.RadToolTip.getCurrent();
                if (tooltip) {
                    tooltip.hide();
                };
            }
            function OkToolTip()
            {
                if (aVs.style.display == "none")
                {
                    CloseToolTip();
                    ajaxManager.ajaxRequest("RT_LOT");
                };
            }
        </script>

    </telerik:RadCodeBlock>
    <telerik:RadAjaxManager ID="radAjaxManager" runat="server">
    </telerik:RadAjaxManager>
    <telerik:RadToolBar ID="toolBar" runat="server" Width="100%" AutoPostBack="True"
        OnButtonClick="toolBar_ButtonClick">
        <Items>
            <telerik:RadToolBarButton runat="server" Value="CRT" ImageUrl="~/images/Creer.gif">
            </telerik:RadToolBarButton>
        </Items>
    </telerik:RadToolBar>
    <telerik:RadToolTip ID="RT_LOT" runat="server" HideEvent="FromCode" Modal="True"
        Position="Center" RelativeTo="BrowserWindow" ShowCallout="False" VisibleOnPageLoad="false">
        <br />
        <table style="border-color: #0000FF; border-width: 10px; width: 100%; text-align: left;">
            <tr>
                <td>
                    <asp:Label ID="RT_LOT_LibLabel" runat="server"></asp:Label>
                </td>
                <td>
                    <asp:RequiredFieldValidator ID="RT_LOT_RFV" ValidationGroup="RT_LOT"  runat="server" Display="Dynamic" ErrorMessage="Erreur"
                        ControlToValidate="RT_LOT_Lib" SetFocusOnError="True">*</asp:RequiredFieldValidator>
                </td>
                <td>
                    <asp:TextBox ID="RT_LOT_Lib" runat="server" Width="336px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td colspan="3">
                    <asp:ValidationSummary ValidationGroup="RT_LOT" ID="RT_LOT_VS" DisplayMode="BulletList" runat="server" />
                </td>
            </tr>
            <tr>
                <td>
                    <input id="RT_LOT_Ok" runat="server" type="button" value="Ok" onclick="OkToolTip();"
                        style="width: 80px; color: #008000; font-weight: bold;" />
                </td>
                <td>
                </td>
                <td>
                    <input id="RT_LOT_AnnBt" type="button" value="Annuler" onclick="CloseToolTip();"
                        style="width: 80px; color: #FF0000; font-weight: bold;" />
                </td>
            </tr>
        </table>
    </telerik:RadToolTip>
    </form>
</body>
</html>


Code behind:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Telerik.Web.UI;

namespace Xarc
{
    public partial class MainPage : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                radAjaxManager.AjaxRequest += new RadAjaxControl.AjaxRequestDelegate(manager_AjaxRequest);
                //radAjaxManager.AjaxSettings.AddAjaxSetting(radAjaxManager, RT_LOT);
                radAjaxManager.AjaxSettings.AddAjaxSetting(toolBar, RT_LOT);
            }
            catch (Exception err)
            {
                radAjaxManager.Alert(err.Message);
            }

        }

        protected void manager_AjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e)
        {
            try
            {
                if (e.Argument == @"RT_LOT")
                {
                };
            }
            catch (Exception err)
            {
                radAjaxManager.Alert(err.Message);
            }
        }

        protected void toolBar_ButtonClick(object sender, RadToolBarEventArgs e)
        {
            try
            {
                switch (e.Item.Value)
                {
                    case @"CRT":
                        RT_LOT.Title = @"Creation";
                        RT_LOT_Lib.Text = null;
                        RT_LOT.Show();
                        break;
                }
            }
            catch (Exception err)
            {
                radAjaxManager.Alert(err.Message);
            }
        }
    }
}



0
Svetlina Anati
Telerik team
answered on 30 Mar 2011, 04:00 PM
Hi Bernard,

 Thank you for the runnable code, I built up a test demo and I was able to reproduce the issue. However, it does not come from the RadToolTip control and the validation does not work if you remove the tooltip at all. To have validation working in general, you should use a submit button and also set the validation group.

This being said, you should modify your code as follows:

<table style="border-color: #0000FF; border-width: 10px; width: 100%; text-align: left;">
         <tr>
             <td>
                 <asp:Label ID="RT_LOT_LibLabel" runat="server"></asp:Label>
             </td>
             <td>
                 <asp:RequiredFieldValidator ID="RT_LOT_RFV" ValidationGroup="RT_LOT" runat="server"
                     Display="Dynamic" ErrorMessage="Erreur" ControlToValidate="RT_LOT_Lib" SetFocusOnError="True">*</asp:RequiredFieldValidator>
             </td>
             <td>
                 <asp:TextBox ID="RT_LOT_Lib" runat="server" Width="336px"></asp:TextBox>
             </td>
         </tr>
         <tr>
             <td colspan="3">
                 <asp:ValidationSummary ValidationGroup="RT_LOT" ID="RT_LOT_VS" DisplayMode="BulletList"
                     runat="server" />
             </td>
         </tr>
         <tr>
             <td>
                 <input id="RT_LOT_Ok" runat="server" type="submit" value="Ok" onclick="OkToolTip();"
                     style="width: 80px; color: #008000; font-weight: bold;" validationgroup="RT_LOT" />
             </td>
             <td>
             </td>
             <td>
                 <input id="RT_LOT_AnnBt" type="button" value="Annuler" onclick="CloseToolTip();"
                     style="width: 80px; color: #FF0000; font-weight: bold;" />
             </td>
         </tr>
     </table>

Once I made the above changes, everything started working as expected on my side. Please, test it on yours, too and let me know how it goes.

Kind regards,
Svetlina
the Telerik team
0
Bernard
Top achievements
Rank 1
answered on 01 Apr 2011, 06:58 AM
Hello Svetlina,

It's just a silly mistake !
Sorry to disturb you for that...

Thanks a lot

Bernard
Tags
ToolTip
Asked by
Bernard
Top achievements
Rank 1
Answers by
Svetlina Anati
Telerik team
Bernard
Top achievements
Rank 1
Share this question
or