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

Radtooltip + Validation + Radbutton

1 Answer 78 Views
ToolTip
This is a migrated thread and some comments may be shown as answers.
Fraser
Top achievements
Rank 1
Fraser asked on 16 Nov 2011, 12:44 PM
I followed the documentation on using the radtooltip with a standard asp validation summary and standard asp button as per on page:

http://demos.telerik.com/aspnet-ajax/tooltip/examples/clientsideapi/defaultcs.aspx

And successfully got this working, but when I tried to use a radbutton instead of a standard asp button I get a microsoft JScript runtime error: Object Expected

Below is my code:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="nomastervaltest.aspx.vb"
    Inherits="nomastervaltest" %>

<!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></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        </telerik:RadScriptManager>
        <script type="text/javascript">
     //<![CDATA[
            function HideTooltip() {
                var tooltip = Telerik.Web.UI.RadToolTip.getCurrent();
                if (tooltip) tooltip.hide();
            }

            function ShowTooltip() {
                window.setTimeout(function () {
                    var tooltip = $find("RadToolTip1");
                    //API: show the tooltip
                    tooltip.show();
                }, 10);
            }

            function CheckIfShow(sender, args) {
                var summaryElem = document.getElementById("ValidationSummary1");

                //check if summary is visible
                if (summaryElem.style.display == "none") {
                    //API: if there are no errors, do not show the tooltip
                    args.set_cancel(true);
                }
            }

        
     //]]>
        </script>
       
        <asp:TextBox ID="txtCompany" runat="server"></asp:TextBox>
        <asp:RequiredFieldValidator ID="rfvCompany" runat="server" ControlToValidate="txtCompany"
            Text="!" ErrorMessage="The company name is obligatory!">
        </asp:RequiredFieldValidator>
        <telerik:RadButton ID="btnSubmit" Text="Submit" runat="server" OnClientClicking="ShowTooltip()">
        </telerik:RadButton>
        <telerik:RadToolTip runat="server" ID="RadToolTip1" Position="TopRight" HideEvent="ManualClose"
            ShowEvent="FromCode" Width="300px" RelativeTo="Element" EnableShadow="true" OnClientBeforeShow="CheckIfShow"
            TargetControlID="btnSubmit">
           <asp:ValidationSummary ID="ValidationSummary1" runat="server"/>
        </telerik:RadToolTip>
         
    </div>
    </form>
</body>
</html>


Many thanks for your help...
Fraser

1 Answer, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 16 Nov 2011, 02:03 PM
Hello Fraser,

I just answered your support ticket on the matter and I will also paste the important information here for others who may encounter a similar issue. I kindly ask that you post only one thread per issue in the future.


Your issue stems from the way event handlers should be attached to the RadControls. You only need to pass the function name, without the parentheses:
<telerik:RadButton ID="btnSubmit" Text="Submit" runat="server" OnClientClicking="ShowTooltip"
</telerik:RadButton>




All the best,
Marin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
ToolTip
Asked by
Fraser
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Share this question
or