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

Problem with tooltip manager

2 Answers 237 Views
ToolTip
This is a migrated thread and some comments may be shown as answers.
Sunil P
Top achievements
Rank 1
Sunil P asked on 17 Mar 2010, 07:32 AM
I have a radCalender, by clicking on each date cell a popup is getting opened. In Tooltip manager's OnAjaxUpdate event i am binding data to tool tip. Its throwing an exception (other than IE browsers, In IE working fine) as 

RadToolTipManager response error:
 Exception=Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 0


And telerik dll version is 2010.1.309.35. Please help me..

Calender.ascx

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Calendar.ascx.cs" Inherits="Transactiv.Commerce.Web.Controls.Common.Calendar" %>

             
 <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
     <script type="text/javascript">
        function ShowToolTip(sender)
        {
            var tooltipManager = $find("<%=RadToolTipManager1.ClientID %>");

               //If the user hovers the image before the page has loaded, there is no manager created
               if (!tooltipManager) return;

               setTimeout("", 3000);
              //Find the tooltip for this element if it has been created
              var tooltip = tooltipManager.getToolTipByElement(sender);
    
              //Create a tooltip if no tooltip exists for such element
              if (!tooltip)
              {                                                  
                  tooltip = tooltipManager.createToolTip(sender);
                  var dateValue = sender.getAttribute("dateInfo");
                  //var neededValue = longValue.substring(longValue.indexOf('_') + 1)
                  tooltip.set_value(dateValue);               
                  tooltip.show();
              }          
         }

            </script>
 </telerik:RadCodeBlock>
       
        <table>
        <tr>
          <td class="calender_txt">Calendar</td>
        </tr>
        <tr>
          <td class="details_txt">
              <telerik:RadCalendar ID="radScheduleCalendar" runat="server"  TitleFormat="MMMM yyyy" Skin="Default"
                    OnDayRender="radScheduleCalendar_DayRender" Width="158px" AutoPostBack="true"   >
              </telerik:RadCalendar>
              <telerik:RadToolTipManager Width="350px" Height="200px" RelativeTo="Element" ID="RadToolTipManager1" HideEvent="ManualClose" ShowEvent="OnClick"
                runat="server" OffsetX="5" Position="MiddleRight" OnAjaxUpdate="RadToolTipmanager1_AjaxUpdate" Skin="Telerik" RenderInPageRoot="true" AnimationDuration="200">
              </telerik:RadToolTipManager>
          </td>
        </tr>
      </table> 
 


Calender.ascx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using System.Xml.Linq;

using Transactiv.Commerce.Web.Base;

namespace Transactiv.Commerce.Web.Controls.Common
{
    public partial class Calendar : BaseUserControl
    {

        protected void Page_Load(object sender, EventArgs e)
        {

            radScheduleCalendar.CultureInfo = new System.Globalization.CultureInfo("en-us");
            radScheduleCalendar.ShowRowHeaders = false;
            radScheduleCalendar.UseColumnHeadersAsSelectors = false;
            radScheduleCalendar.UseRowHeadersAsSelectors = false;
            radScheduleCalendar.EnableMultiSelect = false;
            radScheduleCalendar.SelectedDate = DateTime.Now;
            radScheduleCalendar.EnableEmbeddedSkins = false;
        }
        protected void RadToolTipmanager1_AjaxUpdate(object sender, ToolTipUpdateEventArgs e)
        {
            //e.UpdatePanel.ContentTemplateContainer.Controls.Add(new LiteralControl("<html><body>"));
            //e.UpdatePanel.ContentTemplateContainer.Controls.Add(new LiteralControl(e.Value));
            //e.UpdatePanel.ContentTemplateContainer.Controls.Add(new LiteralControl("</body></html>"));
            SchedulePanel details = (SchedulePanel)this.LoadControl("SchedulePanel.ascx");
            details.Date = DateTime.Parse(e.Value);
            e.UpdatePanel.ContentTemplateContainer.Controls.Add(details);
        }
        protected void radScheduleCalendar_DayRender(object sender, Telerik.Web.UI.Calendar.DayRenderEventArgs e)
        {
            TableCell cell = e.Cell;
            cell.Attributes.Add("dateInfo", e.Day.Date.ToString());
            cell.Attributes.Add("onclick", "ShowToolTip(this);");           
            cell.CssClass = "Appointment";
            e.Cell.Attributes["Title"] = "Click here for more information";

            RadToolTipManager1.TargetControls.Add(cell.ClientID, true);
        }

        private int IsDayRegisteredForTooltip(DateTime date, DateTime eventDate)
        {
            int result;
            if (DateTime.Compare(date, eventDate) == 0)
                result = 1;
            else
                result = -1;
            return result;
        }
    }
}

2 Answers, 1 is accepted

Sort by
0
suthin sadanandan
Top achievements
Rank 1
answered on 19 Mar 2010, 11:42 AM
Please change the "onclick" event to  "onmousedown" event

cell.Attributes.Add("onmousedown", "ShowToolTip(this);");  (Working Code)
//cell.Attributes.Add("onclick", "ShowToolTip(this);"); (Previous code)

0
Svetlina Anati
Telerik team
answered on 22 Mar 2010, 10:36 AM
Hello Sunil,

I examined your code and what I noticed is that you have AutoPostBack = true for the calendar and at the same time you have set OnClick to be the ShowEvent for the RadToolTip. Please, note that this configuration is invalid because what actually happens is that since the tooltip should show onclick it cancels the postback because otherwise there is a logical problem. If you perform a postback onclick this means that the tooltip will not show because the page will be submitted. This being said what I can suggest is to cancel the postback on click and if a postback is needed on some condition after the tooltip is shown to invoke it through the client by using the built-in __doPostBack function.


All the best,
Svetlina
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
ToolTip
Asked by
Sunil P
Top achievements
Rank 1
Answers by
suthin sadanandan
Top achievements
Rank 1
Svetlina Anati
Telerik team
Share this question
or