473,396 Members | 1,929 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Calendar with custom tooltip over days with events

I'm trying to implement a Calendar control using the OnDayRender to get
event information from an XML file. For the days that have special
events, I'd like to make the day bold red and show a tooltip with the
event descriptio nwhen the mouse is over that day.
I was able to do the color and font change for the event days, but I
cannot get the tooltip to work. For some reason the stadard calendar
tooltip with the date still shows.
Can anyone please help?

Please see code below:
------------------------------------------------------------------------
<asp:calendar id="Calendar1" runat="server" BackColor="Bisque"
SelectedDate="<%#DateTime.Today%
DayNameFormat="FirstLetter" font-size="11px"
font-names="tahoma"
selecteddaystyle-backcolor="silver"
style="border-color:#D7D7E5;" width="140"
PrevMonthText="<img src=images/cal_prevMonth.gif
border=0>"
NextMonthText="<img src=images/cal_nextMonth.gif
border=0>">
<TitleStyle BackColor="#D7D7E5"></TitleStyle>
<SelectedDayStyle BackColor="#FBE694"
ForeColor="#000000"
BorderWidth="1px" BorderColor="#BB5503">
</SelectedDayStyle>
<DayHeaderStyle Font-Bold="True"></DayHeaderStyle>
<OtherMonthDayStyle
ForeColor="#999999"></OtherMonthDayStyle>
</asp:calendar>

<script language="VB" runat="server">
Private monthDoc As System.Xml.XmlDocument = New
System.Xml.XmlDocument()
Public Sub calndr_DayRender(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DayRenderEventArgs)
monthDoc.Load(Server.MapPath("dayRenderData.xml"))
If e.Day.IsOtherMonth Then
Exit Sub
End If
Dim dayNumber As String = e.Day.DayNumberText
Dim dayNode As System.Xml.XmlNode = _
monthDoc.SelectSingleNode("/months/month[@index=0" & _
"]/day[@number=" & dayNumber & "]")
If Not dayNode Is Nothing Then
Dim dayItems As System.Xml.XmlNodeList =
dayNode.SelectNodes("item")
For Each dayItem As System.Xml.XmlNode In dayItems
e.Cell.Font.Bold = True
e.Cell.ForeColor = Drawing.Color.Red
e.Cell.ToolTip = dayItem.InnerXml 'THIS LINE
DOESN'T WORK
Next dayItem
End If
End Sub
</script>

Mar 29 '06 #1
1 5227
HI!
1. try the following code (just paste it on your page):

<style type="text/css">#dhtmltooltip { BORDER-RIGHT: black 2px solid;
PADDING-RIGHT: 2px; BORDER-TOP: black 2px solid; PADDING-LEFT: 2px;
Z-INDEX: 100; FILTER:
progid:DXImageTransform.Microsoft.Shadow(color=gra y,direction=135);
VISIBILITY: hidden; PADDING-BOTTOM: 2px; BORDER-LEFT: black 2px solid;
WIDTH: 150px; PADDING-TOP: 2px; BORDER-BOTTOM: black 2px solid;
POSITION: absolute; BACKGROUND-COLOR: lightyellow }
</style>
<DIV id="dhtmltooltip"></DIV>
<SCRIPT type="text/javascript">

/***********************************************
* Cool DHTML tooltip script- C Dynamic Drive DHTML code library
(www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source
code
***********************************************/

var offsetxpoint=-60 //Customize x offset of tooltip
var offsetypoint=20 //Customize y offset of tooltip
var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
var tipobj=document.all? document.all["dhtmltooltip"] :
document.getElementById? document.getElementById("dhtmltooltip") : ""

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")?
document.documentElement : document.body
}

function ddrivetip(thetext, thecolor, thewidth){
if (ns6||ie){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="")
tipobj.style.backgroundColor=thecolor
tipobj.innerHTML=thetext
enabletip=true
return false
}
}

function positiontip(e){
if (enabletip){
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var rightedge=ie&&!window.opera?
ietruebody().clientWidth-event.clientX-offsetxpoint :
window.innerWidth-e.clientX-offsetxpoint-20
var bottomedge=ie&&!window.opera?
ietruebody().clientHeight-event.clientY-offsetypoint :
window.innerHeight-e.clientY-offsetypoint-20

var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of
the context menu
if (rightedge<tipobj.offsetWidth)
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=ie?
ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" :
window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
else if (curX<leftedge)
tipobj.style.left="5px"
else
//position the horizontal position of the menu where the mouse is
positioned
tipobj.style.left=curX+offsetxpoint+"px"

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight)
tipobj.style.top=ie?
ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px"
: window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
else
tipobj.style.top=curY+offsetypoint+"px"
tipobj.style.visibility="visible"
}
}

function hideddrivetip(){
if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}

document.onmousemove=positiontip

</SCRIPT>
2. now in the calndr_DayRender() use it the following way:

e.Cell.Attributes.Add("onMouseover", "ddrivetip('" & dayStr &
"','Khaki', 300);")
e.Cell.Attributes.Add("onMouseout", "hideddrivetip();")

where the dayStr is the variable containing the string to be displayed
in the tooltip.

regards,
krzyhoo

Mar 30 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Tinus | last post by:
Hello all, I've created a custom control that draws a monthly schedule (using the Draw function in C#). Basically it draws 31 boxes and writes the day number in every box. This works...
3
by: Luis E Valencia | last post by:
I have a table that says for example 01/05/2004 Party IIsadpaks 01/06/2004 Party 2394923423 A events table. I want to make a calendar and that the days that are events are inbold and with...
1
by: Peter | last post by:
I have a dilemna. Currently I have created a custom calendar webcontrol that a user can select and will dump the date along with some specialized information set in the tooltip. It actually is...
27
by: Dino M. Buljubasic | last post by:
I'd like to build a calendar displaying all days in a month in a grid so that when I click on the header of a square representing a day of month, I can add a new meeting etc. I know that .net...
3
by: brianwolters | last post by:
Hello, I have a calendar and a textbox right below it on my webpage. I need help with creating some code to display information about the date the user clicked in the text box below it. For...
2
by: Kajsa Anka | last post by:
Before I re-invent something I would like to ask if there exists some code that can be used for create the HTML code for a calendar which I then can include on a web page. The module in the...
1
by: ITistic | last post by:
I am in the planning stages of a new web application. One of the requirements for this application is to provide a Google Calendar type interface to show important events which will be pulled from...
1
by: swethak | last post by:
Hi, I am desiging the calendar application for that purpose i used the below code. But it is for only displys calendar. And also i want to add the events to calendar. In that code displys the...
1
by: swethak | last post by:
hi, i have a code to disply the calendar and add events to that. It works fine.But my requirement is to i have to disply a weekly and daily calendar.Any body plz suggest that what modifications i...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.