I'm try to create event calendar with these detail bellowing;
xml file name ( events.xml)
<?xml version="1.0" encoding="utf-8" ?>
<elements>
<event id ="1" title ="Project" venue ="Townplus hamark" date ="May 20, 2011" time ="6" timeCode ="p" lengthOfEventInMts ="60"></event>
<event id ="2" title ="Project" venue ="Townplus hamark" date ="May 15, 2011" time ="6" timeCode ="p" lengthOfEventInMts ="60"></event>
<event id ="3" title ="Project" venue ="Townplus hamark" date ="May 5, 2011" time ="6" timeCode ="p" lengthOfEventInMts ="60"></event>
</elements>
for my .aspx ( name calendar.aspx)
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="calendar.aspx.vb" Inherits="calendar" %>
<!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>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Calendar runat ="server" ID ="eventSCal" BackColor="White"
BorderColor="White" BorderWidth="1px" Font-Names="Verdana" Font-Size="9pt"
ForeColor="Black" Height="592px" NextPrevFormat="FullMonth" Width="857px">
<SelectedDayStyle BackColor="#333399" ForeColor="White" />
<TodayDayStyle BackColor="#CCCCCC" />
<OtherMonthDayStyle ForeColor="#999999" />
<NextPrevStyle Font-Bold="True" Font-Size="8pt" ForeColor="#333333"
VerticalAlign="Bottom" />
<DayHeaderStyle Font-Bold="True" Font-Size="8pt" />
<TitleStyle BackColor="White" BorderColor="Black" BorderWidth="4px"
Font-Bold="True" Font-Size="12pt" ForeColor="#333399" />
</asp:Calendar>
<asp:DetailsView runat ="server" ID ="eventsDetails"></asp:DetailsView>
</div>
</form>
</body>
</html>
for my code
================================================================
Imports System.Xml.Linq
Partial Class calendar
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim myEventsDocument As XDocument = XDocument.Load(Server.MapPath("events.xml"))
Dim myEventsResultSet = From myEvent In myEventsDocument.Descendants("events") _
Select New With { _
.eventName = myEvent.Attribute("title").Value, _
.eventVenue = myEvent.Attribute("venue").Value, _
.eventDate = myEvent.Attribute("date").Value, _
.eventTime = myEvent.Attribute("time").Value, _
.eventDuration = myEvent.Attribute("lengthOfEventInMts").Value}
Cache.Insert("eventCache", myEventsResultSet, New CacheDependency(Server.MapPath("events.xml")))
End Sub
Protected Sub eventsCal_DayRender(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DayRenderEventArgs) Handles eventsCal.DayRender
Dim myItemCache As IEnumerable = CType(Cache.Item("eventCache"), IEnumerable)
For Each myItem In myItemCache
If String.Equals(DateTime.Parse(myItem.eventDate).ToString("MMM dd yyyy"), e.Day.Date.ToString("MMM dd yyyy")) Then
Dim myEventNameLiteral As New Literal()
myEventNameLiteral.Mode = LiteralMode.PassThrough
myEventNameLiteral.Text = "<br/> <span style ='font-family:verdana;font-size:10px '>" & myItem.eventName & "<br/>"
e.Cell.Controls.Add(myEventNameLiteral)
End If
Next
End Sub
End Class
=============================================================
when i try to debuging , i haven't found any error from my code, but i can't see anything appear on my calendar as well like this
i have no idia for it right now, please help me i'm just a baby with VB.
Thank you very much for your kind to spend yoor time to read this topic. Haha
Regards,
Yenta4
xml file name ( events.xml)
<?xml version="1.0" encoding="utf-8" ?>
<elements>
<event id ="1" title ="Project" venue ="Townplus hamark" date ="May 20, 2011" time ="6" timeCode ="p" lengthOfEventInMts ="60"></event>
<event id ="2" title ="Project" venue ="Townplus hamark" date ="May 15, 2011" time ="6" timeCode ="p" lengthOfEventInMts ="60"></event>
<event id ="3" title ="Project" venue ="Townplus hamark" date ="May 5, 2011" time ="6" timeCode ="p" lengthOfEventInMts ="60"></event>
</elements>
for my .aspx ( name calendar.aspx)
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="calendar.aspx.vb" Inherits="calendar" %>
<!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>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Calendar runat ="server" ID ="eventSCal" BackColor="White"
BorderColor="White" BorderWidth="1px" Font-Names="Verdana" Font-Size="9pt"
ForeColor="Black" Height="592px" NextPrevFormat="FullMonth" Width="857px">
<SelectedDayStyle BackColor="#333399" ForeColor="White" />
<TodayDayStyle BackColor="#CCCCCC" />
<OtherMonthDayStyle ForeColor="#999999" />
<NextPrevStyle Font-Bold="True" Font-Size="8pt" ForeColor="#333333"
VerticalAlign="Bottom" />
<DayHeaderStyle Font-Bold="True" Font-Size="8pt" />
<TitleStyle BackColor="White" BorderColor="Black" BorderWidth="4px"
Font-Bold="True" Font-Size="12pt" ForeColor="#333399" />
</asp:Calendar>
<asp:DetailsView runat ="server" ID ="eventsDetails"></asp:DetailsView>
</div>
</form>
</body>
</html>
for my code
================================================================
Imports System.Xml.Linq
Partial Class calendar
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim myEventsDocument As XDocument = XDocument.Load(Server.MapPath("events.xml"))
Dim myEventsResultSet = From myEvent In myEventsDocument.Descendants("events") _
Select New With { _
.eventName = myEvent.Attribute("title").Value, _
.eventVenue = myEvent.Attribute("venue").Value, _
.eventDate = myEvent.Attribute("date").Value, _
.eventTime = myEvent.Attribute("time").Value, _
.eventDuration = myEvent.Attribute("lengthOfEventInMts").Value}
Cache.Insert("eventCache", myEventsResultSet, New CacheDependency(Server.MapPath("events.xml")))
End Sub
Protected Sub eventsCal_DayRender(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DayRenderEventArgs) Handles eventsCal.DayRender
Dim myItemCache As IEnumerable = CType(Cache.Item("eventCache"), IEnumerable)
For Each myItem In myItemCache
If String.Equals(DateTime.Parse(myItem.eventDate).ToString("MMM dd yyyy"), e.Day.Date.ToString("MMM dd yyyy")) Then
Dim myEventNameLiteral As New Literal()
myEventNameLiteral.Mode = LiteralMode.PassThrough
myEventNameLiteral.Text = "<br/> <span style ='font-family:verdana;font-size:10px '>" & myItem.eventName & "<br/>"
e.Cell.Controls.Add(myEventNameLiteral)
End If
Next
End Sub
End Class
=============================================================
when i try to debuging , i haven't found any error from my code, but i can't see anything appear on my calendar as well like this
i have no idia for it right now, please help me i'm just a baby with VB.
Thank you very much for your kind to spend yoor time to read this topic. Haha
Regards,
Yenta4