Hi,
I am trying to set on my intranet website an online event calendar using ASP.NET vb.net and an access 2000 database.
Everything is working nicely since I can add new events,display and update them no problem.
The only problem is that when displayed on the calendar, all the
" event starting time" come in this format : 12/30/1899 7:30 Am
when I only want the time to display on the 7:30 AM like format.Please help !
You can find below my code :
Please help, this is very urgent !
I am trying to set on my intranet website an online event calendar using ASP.NET vb.net and an access 2000 database.
Everything is working nicely since I can add new events,display and update them no problem.
The only problem is that when displayed on the calendar, all the
" event starting time" come in this format : 12/30/1899 7:30 Am
when I only want the time to display on the 7:30 AM like format.Please help !
You can find below my code :
HTML:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "[url="http://www.w3.org/TR/html4/loose.dtd"]http://www.w3.org/TR/html4/loose.dtd[/url]">
<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<script runat="server">
Dim ds As New DataSet()
Protected Sub Page_Load(Src As [Object], E As EventArgs)
'Note: The following two lines of code should be on the same line.
Dim connectionstring As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("aspnet_calendar.mdb") + ";"
Dim sql As String = "select * from events"
'Create a DataAdapter
Dim da As New OleDbDataAdapter(sql, connectionstring)
'Fill the DataSet (ds)
da.Fill(ds, "events")
End Sub
Protected Sub eventscalendar_DayRender(Src As [Object], E As DayRenderEventArgs)
'use a StringBuilder object for optimized string concatenation
Dim strEvents As New StringBuilder()
strEvents.Append("<span style=""font-size:80%"">")
Dim row As DataRow
For Each row In ds.Tables("events").Rows
Dim eventdate As DateTime = CType(row("eventdate"), DateTime)
If eventdate.Equals(E.Day.Date) Then
'strEvents.Append("<br />" + row["eventtext"]);
' MODIFICATICATION mhb CI-DESSOUS
'CType(row("eventdate"), DateTime.Now.ToString("t")
strEvents.Append(("<br />" + row("eventtext") + "<br />" + row("startingtime")))
End If
Next row
'Close off the string in the strEvents StringBuilder
strEvents.Append("</span>")
'Add the string to the cell in a LiteralControl
E.Cell.Controls.Add(New LiteralControl(strEvents.ToString()))
End Sub 'eventscalendar_DayRender
</script>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<form runat="server">
<asp:calendar BackColor="#FFFFCC" DayHeaderStyle-BackColor="#FFFFFF" DayStyle-HorizontalAlign="right" Font-Size="16" Height="100%" ID="eventcalendar" NextPrevStyle-BackColor="#99FFCC" runat="server" ShowDayHeader="true" ShowGridLines="true" ShowNextPrevMonth="true" TitleFormat="MonthYear" TitleStyle-ForeColor="#0000FF" WeekendDayStyle-BackColor="#FFCCFF" Width="100%"
OnDayRender="eventscalendar_DayRender" align="center"></asp:calendar>
</form >
</div>
</body>
</html>
Please help, this is very urgent !
Last edited by a moderator: