在我的自定义表单上,我想显示一个自定义Guid字段.
我通过一个功能以通常的方式创建了该字段:
<Field ID="88813c02-799b-4fc8-8ed8-72fe668e257c" Type="Guid"
Name="myGuid"
StaticName="myGuid"
DisplayName="My Guid" />
Run Code Online (Sandbox Code Playgroud)
我希望首先通过代码设置此字段并在表单上显示.在表单上我有以下控件(供参考我还包括一个标题字段):
<SharePoint:GuidField runat="server" ID="myGuidField" FieldName="myGuid" />
<SharePoint:TextField runat="server" ID="myTitle" FieldName="Title" />
Run Code Online (Sandbox Code Playgroud)
Guid字段不会显示在常规的New/Edit表单上 - 它只是空的.在自定义表单后面的代码中,我可以执行以下操作:
myTitle.Value = "Some Title Value";
string testValue = myTitle.Value; //-->"Some Title Value"
Run Code Online (Sandbox Code Playgroud)
但是当试图设置Guid字段的值时 - 它无法以某种方式完成:
string anotherValue = myGuidField.Value; //--> null
Guid myGuid = new Guid("7f824c3f-4049-4034-a231-85291fce2680");
myGuidField.Value = myGuid;
string anotherValue = myGuidField.Value; //--> still null
//but myGuidField is seen as a "Microsoft.Sharepoint.WebControls.GuidField"
Run Code Online (Sandbox Code Playgroud)
所以不知怎的,我只是无法以编程方式设置Guid值,而且我也无法只显示Guid.
两个问题: