日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

SharePoint Calendar Webparts

發(fā)布時(shí)間:2024/10/8 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 SharePoint Calendar Webparts 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

入門請看KaneBoy寫很好的入門的ppt----Walkthrough-WebPart
第一個(gè)webpart 是Event Calendar 讀取Event,比較簡單,重寫Calendar控件就可以了,我參考了CodeProject的一位前輩?
Custom_Calendar_Web_Part,不過那個(gè)的取時(shí)間有點(diǎn)問題,自己笨笨的寫了一個(gè)
Code
//沒貼CSS上來??將注釋去掉就行了

using?System;
using?System.Runtime.InteropServices;
using?System.Web.UI;
using?System.Web.UI.WebControls;
using?System.Web.UI.WebControls.WebParts;
using?System.Xml.Serialization;

using?Microsoft.SharePoint;
using?Microsoft.SharePoint.WebControls;
using?Microsoft.SharePoint.WebPartPages;
using?Microsoft.SharePoint.Utilities;
using?System.ComponentModel;

namespace?SharePoint.Panda.Calendar?{
????[Guid?(?
"9c7c129b-9442-4d16-a30f-c1d43c35c0e3"?)]
????
public?class?WebPart1?:?System.Web.UI.WebControls.WebParts.WebPart?{
????????
public?WebPart1?()?{
????????}
????????System.Web.UI.WebControls.Calendar?cal;
????????
string?url;
????????Literal?redire?
=?new?Literal?();

????????
private?string?_eventName?=?"CLP.SRS.Events";?//list?name
????????[Personalizable?(?PersonalizationScope.Shared?),?WebBrowsable?(?true?),?WebDisplayName?(?"Event?name"?),?WebDescription?(?"Input?event?name"?)]
????????
public?string?eventName?{
????????????
get?{?return?_eventName;?}
????????????
set?{?_eventName?=?value;?}
????????}
????????
protected?override?void?OnInit?(?EventArgs?e?)?{
????????????
this.EnsureChildControls?();
????????????
this.Load?+=?new?EventHandler?(Calendar_Load);
????????????
base.OnInit?(?e?);
????????}
????????
void?Calendar_Load?(?object?sender,?EventArgs?e?)?{
????????????
if?(?string.IsNullOrEmpty?(?Page.Request.Url.ToString()?)?)?{
????????????????
return;
????????????}
????????????
if?(?this.WebPartManager.DisplayMode?==?WebPartManager.EditDisplayMode?)?{
????????????????
return;
????????????}
????????}

????????
protected?override?void?CreateChildControls?()?{
????????????cal?
=?new?System.Web.UI.WebControls.Calendar?();
????????????
this.cal.ID?=?"Calendar";
????????????
//this.cal.BorderColor?=?System.Drawing.ColorTranslator.FromHtml?(?"#f1f9e2"?);
????????????
//this.cal.BorderStyle?=?BorderStyle.Solid;
????????????
//this.cal.BorderColor?=?System.Drawing.ColorTranslator.FromHtml?(?"#f1f9e2"?);
????????????
//this.cal.BorderWidth?=?0;
????????????
//this.cal.SelectorStyle.Font.Bold?=?true;
????????????this.cal.CssClass?=?"CLPSRS_Calendar";
????????????
this.cal.TitleStyle.CssClass?=?"Calenader_Header";
????????????
//this.cal.DayHeaderStyle.ForeColor?=?System.Drawing.ColorTranslator.FromHtml?(?"#818080"?);
????????????
//this.cal.OtherMonthDayStyle.ForeColor?=?System.Drawing.ColorTranslator.FromHtml?(?"#f1f9e2"?);
????????????
//this.cal.OtherMonthDayStyle.BackColor?=?System.Drawing.ColorTranslator.FromHtml?(?"#f1f9e2"?);????????
????????????
//this.cal.OtherMonthDayStyle.Font.Bold?=?false;

????????????
this.cal.OtherMonthDayStyle.CssClass?=?"Calendar_IsOtherMonth";
????????????
//this.cal.SelectedDayStyle.ForeColor?=?System.Drawing.ColorTranslator.FromHtml?(?"#818080"?);
????????????
//this.cal.SelectedDayStyle.BackColor?=?System.Drawing.ColorTranslator.FromHtml?(?"#ffffff"?);
????????????this.cal.SelectedDayStyle.CssClass?=?"Calendar_SelectedDay";
????????????
this.cal.DayRender?+=?new?System.Web.UI.WebControls.DayRenderEventHandler?(?OnDayRender?);
????????????
this.cal.SelectionChanged?+=?new?EventHandler?(?this.cal_SelectionChanged?);
????????????
this.Controls.Add?(?cal?);
????????????
this.Controls.Add?(?redire?);

????????}
????????
protected?void?cal_SelectionChanged?(?object?sender,?EventArgs?e?)?{
????????????System.Web.UI.WebControls.Calendar?sendCal?
=?(?System.Web.UI.WebControls.Calendar?)?sender;
????????????RenderEventsByDate?(?sendCal.SelectedDate?);
????????}

????????
private?void?RenderEventsByDate?(?DateTime?selectedDate?)?{
????????????
if?(?!string.IsNullOrEmpty?(?eventName?)?)?{
????????????????SPSecurity.RunWithElevatedPrivileges?(?
delegate?()?{
????????????????????
using?(?SPSite?site?=?new?SPSite?(?SPContext.Current.Site.ID?)?)?{
????????????????????????
try?{
????????????????????????????
using?(?SPWeb?web?=?site.RootWeb?)?{
????????????????????????????????
try?{
????????????????????????????????????SPList?calendarList?
=?web.Lists?[eventName];
????????????????????????????????????SPQuery?query?
=?new?SPQuery?();
????????????????????????????????????query.Query?
=?string.Format?(?"<Where><Eq><FieldRef?Name='EventDate'/><Value?Type='DateTime'>{0}</Value></Eq></Where>",?SPUtility.CreateISO8601DateTimeFromSystemDateTime?(?selectedDate?)?);
????????????????????????????????????SPListItemCollection?calendarItems?
=?calendarList.GetItems?(?query?);
????????????????????????????????????url?
=?SPContext.Current.Web.Url?+?"/Lists/"?+?eventName.Replace?(?".",?""?)?+?"/calendar.aspx?CalendarDate="?+
?????????????????????????????????????????selectedDate.Month.ToString?()?
+?"/"?+?selectedDate.Day.ToString?()?+?"/"?+
?????????????????????????????????????????selectedDate.Year.ToString?()?
+?"&CalendarPeriod=month";
????????????????????????????????????redire.Text?
=?"<script?language='javascript'>window.location='"?+?url?+?"'</script>";

????????????????????????????????}?
catch?(?Exception?ee?)?{
????????????????????????????????????web.Dispose?();
????????????????????????????????????
string?error?=?ee.ToString?();
????????????????????????????????}
????????????????????????????}
????????????????????????}?
catch?(?Exception?ee?)?{
????????????????????????????site.Dispose?();
????????????????????????????
string?error?=?ee.ToString?();
????????????????????????}
????????????????????}
????????????????}?);
????????????}
????????}

????????
protected?void?OnDayRender?(?object?sender,?DayRenderEventArgs?e?)?{
????????????CalendarDay?day?
=?(?(?DayRenderEventArgs?)?e?).Day;
????????????TableCell?cell?
=?(?(?DayRenderEventArgs?)?e?).Cell;
????????????cell.CssClass?
=?"Calendar_Day";
????????????
//cell.Style.Add?(?"color",?"#818080"?);
????????????if?(?day.IsToday?&&?!day.IsOtherMonth?)?{
??????????????
//?cell.Font.Bold?=?true;
???????????????
//cell.BackColor?=?System.Drawing.ColorTranslator.FromHtml?(?"#6f8c16"?);
????????????????cell.CssClass?=?"Calendar_IsToday";
????????????}?
else?if?(?day.IsOtherMonth?)?{???????????????
????????????????
//cell.Style.Add?(?"color",?"#f1f9e2"?);
????????????????cell.CssClass?=?"Calendar_IsOtherMonth";
????????????????cell.Text?
=?"&nbsp";
????????????}
????????????
if?(!day.IsOtherMonth?){
????????????????
if?(?!string.IsNullOrEmpty?(?eventName?)?)?{
????????????????????SPSecurity.RunWithElevatedPrivileges?(?
delegate?()?{
????????????????????????
using?(?SPSite?site?=?new?SPSite?(?SPContext.Current.Site.ID?)?)?{
????????????????????????????
try?{
????????????????????????????????
using?(?SPWeb?web?=?site.RootWeb?)?{
????????????????????????????????????
try?{
????????????????????????????????????????SPQuery?query?
=?new?SPQuery?();
????????????????????????????????????????query.Query?
=?string.Format?(?"<Where><Eq><FieldRef?Name='EventDate'/><Value?Type='DateTime'>{0}</Value></Eq></Where>",?SPUtility.CreateISO8601DateTimeFromSystemDateTime?(?day.Date?)?);
????????????????????????????????????????SPListItemCollection?calendarItems?
=?web.Lists?[eventName].GetItems?(?query?);
????????????????????????????????????????
if?(?calendarItems.Count?>?0?)?{
????????????????????????????????????????????
//cell.BackColor?=?System.Drawing.Color.Khaki;
????????????????????????????????????????????cell.CssClass?=?"Calendar_EventDay";
????????????????????????????????????????}
????????????????????????????????????}?
catch?(?Exception?ee?)?{
????????????????????????????????????????web.Dispose?();
????????????????????????????????????????
string?error?=?ee.ToString?();
????????????????????????????????????}
????????????????????????????????}
????????????????????????????}?
catch?(?Exception?ee?)?{
????????????????????????????????site.Dispose?();
????????????????????????????????
string?error?=?ee.ToString?();
????????????????????????????}
????????????????????????}
????????????????????}?);
????????????????}
????????????}

????????}
????????
protected?override?void?Render?(?HtmlTextWriter?writer?)?{
????????????EnsureChildControls?();
????????????redire.RenderControl?(?writer?);
????????????cal.RenderControl?(?writer?);
????????}
????}
}

然后部署Webpart..... 就不說了


?? 已經(jīng)更新了 SharePoint Event Calendar Recurrence 屬性

轉(zhuǎn)載于:https://www.cnblogs.com/chris_thanks/archive/2009/01/17/1377617.html

總結(jié)

以上是生活随笔為你收集整理的SharePoint Calendar Webparts的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。