Sharepoint控件和Web部件C#说明
我正在学习使用web部件的SharePoint,我正在尝试找出此示例代码以及我所做的工作。 这是样品Sharepoint控件和Web部件C#说明,c#,sharepoint,web-parts,C#,Sharepoint,Web Parts,我正在学习使用web部件的SharePoint,我正在尝试找出此示例代码以及我所做的工作。 这是样品 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.Sha
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;
namespace SampleWebpart1
{
[Guid("cf5f3fd5-1776-4c47-9587-4f6fe4f3d645")]
public class SampleWebpart1 : Microsoft.SharePoint.WebPartPages.WebPart
{
public SampleWebpart1() { }
protected override void CreateChildControls()
{
base.CreateChildControls();
SharePointCalendar calendar = new SharePointCalendar();
Controls.Add(calendar);
}
}
public class SharePointCalendar : Control
{
private SPCalendarView _view;
/// Create the SharePoint calendar. Uses the SharePoint SPCalendarView object.
protected override void CreateChildControls()
{
base.CreateChildControls();
_view = new SPCalendarView();
_view.EnableViewState = true;
_view.Width = Unit.Percentage(100);
_view.DataSource = GetCalendarItems();
DataBind();
Controls.Add(_view);
}
private SPCalendarItemCollection GetCalendarItems()
{
// Create a new collection for the calendar items
// This is an item with a start and end date.
SPCalendarItemCollection items = new SPCalendarItemCollection();
// Add the first dummy item
SPCalendarItem item = new SPCalendarItem();
item.StartDate = DateTime.Now;
item.EndDate = DateTime.Now.AddHours(1);
item.hasEndDate = true;
item.Title = "First calendar item";
item.DisplayFormUrl = "/News";
item.Location = "USA";
item.Description = "This is the first test item in the calendar rollup";
item.IsAllDayEvent = false;
item.IsRecurrence = false;
item.CalendarType = Convert.ToInt32(SPCalendarType.Gregorian);
items.Add(item);
// Add the second item. This is an all day event.
SPCalendarItem item2 = new SPCalendarItem();
item2.StartDate = DateTime.Now.AddDays(-1);
item.hasEndDate = true;
item2.Title = "Second calendar item";
item2.DisplayFormUrl = "/News";
item2.Location = "India";
item2.Description = "This is the second test item in the calendar rollup";
item2.IsAllDayEvent = true;
item2.IsRecurrence = false;
item2.CalendarType = Convert.ToInt32(SPCalendarType.Gregorian);
items.Add(item2);
// return the collection
return items;
}
}
}
这就是我正在做的,我的第一个问题是这是什么
[Guid(“cf5f3fd5-1776-4c47-9587-4f6fe4f3d645”)]表示或不表示。我在XNA中看到过类似的东西,但那是用于内容处理的
这一行中的:表示公共类SharePointCalendar:Control的什么意思
这是说类扩展了控件吗
这一切是怎么回事?为什么会有一个uuu前视图
_view = new SPCalendarView();
_view.EnableViewState = true;
_view.Width = Unit.Percentage(100);
_view.DataSource = GetCalendarItems();
感谢您的帮助:)破折号表示变量是私有的,这是可选的,您可以随意命名它们。但大多数编程语言都遵循这种命名约定的模式,我认为在开始在SharePoint中开发之前,您应该了解这种模式:)
- Public-first字母为大写
- 受保护-第一个字母为小写
- _private-第一个字母是破折号,后跟小写字母
在本例中,我几乎看不到或根本没有理由使用guid,除非您计划在远程系统中运行Web部件或通过外部程序集或类似的方式访问它。在开始SharePoint开发之前,您应该学习C#和ASP.NET—“C#逐步”和“ASP.NET逐步”(Microsoft出版社)虽然你可以从很多书开始,但它们都是很棒的入门读物。首先学习C#,然后升级到ASP.NET。之后,您就可以开始SharePoint开发了。一个很好的起点应该是像《开始SharePoint 2010开发》(WROX)出版社这样的书 GUID代表“全局唯一标识符”-它是可以分配给Windows中任何资源的唯一ID。guid也可以被称为“银河系唯一标识符”,因为任何两个guid都不可能重复
类声明中的冒号表示该类从控件继承。这些是非常基本的问题。也许你应该先学C。