Radtooltip + Validation + Radbutton

2 posts, 0 answers
  1. Fraser
    Fraser avatar
    5 posts
    Member since:
    Sep 2011

    Posted 16 Nov 2011 Link to this post

    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
  2. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3602 posts

    Posted 16 Nov 2011 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top