SPFieldLink.Name property
取得欄位 reference 物件的內部名稱。
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'宣告
Public ReadOnly Property Name As String
Get
'用途
Dim instance As SPFieldLink
Dim value As String
value = instance.Name
public string Name { get; }
Property value
Type: System.String
物件的內部名稱。
備註
此屬性的值是SPField物件是做為引數傳遞給SPFieldLink建構函式InternalName屬性的值相同。
Examples
下列範例會顯示主控台應用程式,逐一檢查的欄位和欄位連結集合的內容類型,並再列印每一個欄位InternalName屬性的值以及主控台的對應欄位連結Name屬性的值。
Imports System
Imports Microsoft.SharePoint
Module ConsoleApp
Sub Main()
Dim site As SPSite = New SPSite("https://localhost")
Try
Dim web As SPWeb = site.OpenWeb()
Try
Dim ctName As String = "Announcement"
Dim contentType As SPContentType = web.ContentTypes(ctName)
If contentType IsNot Nothing Then
For i As Integer = 0 To contentType.Fields.Count - 1
Console.WriteLine("Field.InternalName = {0}", contentType.Fields(i).InternalName)
Console.WriteLine("FieldLink.Name = {0}", contentType.FieldLinks(i).Name)
Console.WriteLine()
Next
End If
Finally
web.Dispose()
End Try
Finally
site.Dispose()
End Try
Console.Write("Press ENTER to continue...")
Console.ReadLine()
End Sub
End Module
using System;
using Microsoft.SharePoint;
namespace Test
{
class ConsoleApp
{
static void Main(string[] args)
{
using (SPSite site = new SPSite("https://localhost"))
{
using (SPWeb web = site.OpenWeb())
{
string ctName = "Announcement";
SPContentType contentType = web.ContentTypes[ctName];
if (contentType != null)
{
for (int i = 0; i < contentType.Fields.Count; i++)
{
Console.WriteLine("Field.InternalName = {0}", contentType.Fields[i].InternalName);
Console.WriteLine("FieldLink.Name = {0}", contentType.FieldLinks[i].Name);
Console.WriteLine();
}
}
}
}
Console.Write("Press ENTER to continue...");
Console.ReadLine();
}
}
}
應用程式會在列印下列輸出至主控台。
Field.InternalName = ContentType
FieldLink.Name = ContentType
Field.InternalName = Title
FieldLink.Name = Title
Field.InternalName = Body
FieldLink.Name = Body
Field.InternalName = Expires
FieldLink.Name = Expires
Press ENTER to continue...
請參閱
參照
Microsoft.SharePoint namespace