We help IT Professionals succeed at work.

calendar control - i assume a tooltip but not sure how to do it.

i would like to add a calendar to my website that when I hover over a date it reads the data from my sql server for that date.

For example I have managers on call different days of the weeks. if I hover over the date I want it to show who is on call.

a working example would be wonderful...  Thanks!
Comment
Watch Question

Author

Commented:
I thought something along these lines but can't get it to work:
Imports System.Data.SqlClient

Partial Class main
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load

        Dim ConnectionString As String = System.Web.Configuration.WebConfigurationManager.ConnectionStrings("dbconn").ToString()
        Dim Id As String = "1"

        Dim MyConn As New System.Data.SqlClient.SqlConnection(ConnectionString)
        Dim MyComm As New System.Data.SqlClient.SqlCommand("SELECT * FROM [dbo].[Table] WHERE id = " + Id, MyConn)

        MyConn.Open()
        Dim DataReader As System.Data.SqlClient.SqlDataReader = MyComm.ExecuteReader()

        While (DataReader.Read())




        End While

        DataReader.Close()
        MyConn.Close()


    End Sub


    Protected Sub Calendar1_DayRender(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DayRenderEventArgs)
        Dim ConnectionString As String = System.Web.Configuration.WebConfigurationManager.ConnectionStrings("dbconn").ToString()



        Dim MyConn As New System.Data.SqlClient.SqlConnection(ConnectionString)
        Dim MyComm As New System.Data.SqlClient.SqlCommand("SELECT * FROM [dbo].[docs] WHERE date = " + Calendar1.SelectedDate, MyConn)

        MyConn.Open()
        Dim DataReader As System.Data.SqlClient.SqlDataReader = MyComm.ExecuteReader()

        While (DataReader.Read())
            Calendar1.ToolTip = "the date is" + Calendar1.SelectedDate

            

        End While

        DataReader.Close()
        MyConn.Close()






    End Sub

End Class

Open in new window

then in the aspx take and call the following:
<asp:Calendar ID="Calendar1" runat="server" OnDayRender="Calendar1_DayRender"  ></asp:Calendar>
Most Valuable Expert 2012
Top Expert 2008
Commented:
For custom day tool tips, you can set them in the DayRender event handler, by accessing the e.Cell.ToolTip property.

Author

Commented:
thanks that worked.