2013-03-29 35 views
0

可以任何請告訴我如何突出顯示與綠色和粉紅色兩種顏色的c#日曆日期 如果是的話,我可以appy div日曆上的顏色 然後如何? 目前我的代碼是如何突出顯示與DIV顏色的C#日曆控制

    if(dt.Rows.Count>1) 
       { 
        cell.BackColor = System.Drawing.Color.Yellow; 
        //cell.Style.Add("font-weight", "bold"); 
        //cell.Style.Add("color", "pink"); 
        //cell.ForeColor = System.Drawing.Color.Pink; 
       //foreach (var item in collection) 
        //{ 

        //} 
        // cell.Controls.Add("divColor"); 

        // cell.BackColor = System.Drawing.Color.Magenta; 
       } 

       if (dCalendarDate == tempDate) 
       { 

        ViewState["ManagerID"] = iManagerID; 
        //Session["tempid"] = iManagerID; 
        // int tempdate1 = iManagerID; 
        // if (tempid != iManagerID) 
        //{ 
         // tblColorCodes clr = new tblColorCodes(); 
         //clr.GetColor(tempid); 



         //} 
        DateTime tempdate2 = tempDate; 


        tblColorCodes objColorCode = new tblColorCodes(); 
        objColorCode.GetColor(iManagerID); 
        string colorCode = objColorCode.ColorCode; 
        cell.BackColor = System.Drawing.Color.FromName(colorCode); 
        strJavascript = "javascript:datePic('" + day.Date + "','" + iManagerID + "');"; 
        if (day.Date >= DateTime.Today) 
        { 
         cell.Attributes.Add("onclick", strJavascript); 
        } 
       } 

      } 
      cell.Style.Add("cursor", "pointer"); 
      if (day.Date < DateTime.Now.Date) 
      { 
       cell.BackColor = System.Drawing.Color.FromArgb(150, 150, 150); 
       cell.ToolTip = "You can’t select a date in the past!"; 
      } 
      //cell.Attributes.Add("onclick", "datePic('" + day.Date + "')"); 

     } 

回答

0

你可以做這樣的事情使用jQuery:(或者達到相同的使用JavaScript的努力一點)

$('#calendarID a').each(function() { 
    if (this.innerText == "14") 
    { 
    this.style.color = 'red'; 
    } 
}); 

這將設置的顏色第14天到紅色。如果你想把它和你的ASP.NET標記結合起來,你應該把calendarID改爲ClientID。你可以用類似的方式改變顏色和日期。您還應該使用css類,而不是直接設置樣式屬性。

相關問題