Rank: Newbie Groups: Member
 
 
Joined: 8/15/2009 Posts: 3 
	 | 
		   
	    
		    Hello,     I am using your Calendar and able to edit it in my way and display it. Below is the code for my DayRender; I am adding as many notes I want to add in a selected day. Notes property is changed as per my custom class
 
    
        Code: Visual Basic.NET
         
        Private Sub CallbackPanel1_Execute(ByVal sender As Object, ByVal e As EO.Web.CallbackEventArgs) Handles CallbackPanel1.Execute
        Dim callbackParam As String = CallbackPanel1.LastTrigger.Parameter
        'Validate the parameter. The first 10 characters
        'is the date. The rest is the note.
        If Not (callbackParam Is Nothing) AndAlso callbackParam.Length > 10 Then
            Dim [date] As String = callbackParam.Substring(0, 10)
            Dim note As String = callbackParam.Substring(10)
            If (String.Compare(note, "Add", True) = 0) Then
                'Notes(EO.Web.Calendar.StringToDate([date])) = note
                Dim newtask As List(Of Task) = TaskNotes(EO.Web.Calendar.StringToDate([date]))
                Dim t As New Task(AddType, TypeColor)
                If (newtask Is Nothing) Then
                    newtask = New List(Of Task)
                    newtask.Add(t)
                Else
                    MsgBox("Exists " + t.TaskNote + newtask.Contains(t).ToString)
                    ' If already contains, then don't add
                    If (newtask.Contains(t) = False) Then
                        newtask.Add(t)
                    End If
                End If
                TaskNotes(EO.Web.Calendar.StringToDate([date])) = newtask
                t = Nothing
                newtask = Nothing
            Else
                MsgBox("Date = " + [date] + " Task to Remove = " + note)
            End If
        End If
    End Sub 'CallbackPanel1_Execute
    Protected Sub Calendar1_DayRender(ByVal sender As Object, ByVal e As EO.Web.DayRenderEventArgs) Handles Calendar1.DayRender
        Dim note As String = CStr(Notes(e.Day.Date))
        Dim tasks As List(Of Task) = TaskNotes(e.Day.Date)
        'Create an ID for this day
        Dim dayId As String = "dayId_" + EO.Web.Calendar.DateToString(e.Day.Date)
        dayId = dayId.Replace("-"c, "_"c)
        Dim typeName As String = ""
        If (Not AddType Is Nothing) Then
            typeName = AddType
        End If
        Dim html As String = "<table id=""{0}"" border=""0"" cellSpacing=""0"" cellPadding=""0"""
        html += "onclick=""AddTask('{0}');"">"  ' EditNote('{0}');
        html += "<tr>"
        html += "    <td align=""right"">"
        html += e.Day.DayNumberText '+ ", " + typeName ' + ", " + TypeColor
        html += "    </td>"
        html += "</tr>"
        If (Not tasks Is Nothing) Then
            Dim t As Task
            For Each t In tasks
                html += "<tr>"
                html += "    <td align=""left"" valign=""top"" style=""width:72px;height:12px;overflow:hidden;line-height:14px;BACKGROUND-COLOR:" & t.TaskColor.Name & ";"" onclick=""RemoveTask('{0}', '" & t.TaskNote & "')"" > "
                html += t.TaskNote
                html += "    </td>"
                html += "</tr>"
            Next
            t = Nothing
        Else
            html += "<tr>"
            html += "    <td align=""left"" valign=""top"" style=""width:72px;height:12px;overflow:hidden;line-height:14px;"">"
            html += "    </td>"
            html += "</tr>"
        End If
        html += "</table>"
        'Dim backgroundColor As String = String.Empty
        'If Not (note Is Nothing) Then
        '    backgroundColor = "BACKGROUND-COLOR:" + TypeColor + ";"
        'End If
        html = String.Format(html, dayId)   ', backgroundColor)
        e.Writer.Write(html)
    End Sub 
     
 
    
        Code: JavaScript
         
        function AddTask(dayId)
{
	//Get the cell in which the edit to take place
	var dayTable = document.getElementById(dayId);
	var s = "Add"  //'document.getElementById(AddType);
	
	//Get the date associated with the cell
	curDate = eo_StringToDate(dayId.substr(6).replace(/_/g, '-'));
  	//Save the note
  	s = eo_DateToString(curDate) + s;
	eo_Callback('<%=CallbackPanel1.ClientID%>', s);
}
function RemoveTask(dayId, tt)
{
    alert(tt)
	//Get the cell in which the edit to take place
	var dayTable = document.getElementById(dayId);
    
	//Get the date associated with the cell
	curDate = eo_StringToDate(dayId.substr(6).replace(/_/g, '-'));
    
    var s = eo_DateToString(curDate) + " " + tt
    alert(s)
    eo_Callback('<%=CallbackPanel1.ClientID%>', s);
} 
     
 
I am able to add multiple <td> in the cell of the table as per the text and background color. If the user clicks again on the added <td>, it fires onclick event for that td and calls RemoveTask and goes to Callback_Execute for removing. But after that it also executes for AddNote.  So, I click on a added td, RemoveTask is called, goes to Callback in the else part and displays a Msgbox and again comes to callback with parameter s as Add which is in AddTask.  Can you help me guide, that after Remove is fired and comes to callback, then again the AddNote shouldn't be executed. How to overcome this problem. Looking ahead for your help.
		  
	 | 
	
		Rank: Administration Groups: Administration
 
 
Joined: 5/27/2007 Posts: 24,427 
	 | 
		   
	     
		    Hi,
  We can only tell you that when you use callback, you can pass eo_Callback different values so that your server side code will be able to distinguish different scenarios and perform different action. Our tech support won't look into the code and troubleshoot any coding problems for you though. 
  Thanks! 
		 
	 |