[英]Hiding Title FIeld in Sharepoint not working
I am trying to do the following to hide the title field from the new and edit form but its still visible. 我正在尝试执行以下操作,以从新表单和编辑表单中隐藏标题字段,但仍可见。
pls help 请帮助
/// <summary>
/// Adds source list and content type.
/// </summary>
/// <param name="currentWeb"></param>
private void AddSourcesList(SPWeb currentWeb)
{
currentWeb.AllowUnsafeUpdates = true;
#region Add Source content type.
if(currentWeb.ContentTypes[SponsoringCommon.Constants.CONTENTTYPES_SOURCES_NAME] == null)
{
#region Hides title column
currentWeb.Lists.Add(SponsoringCommon.Constants.LISTNAMES_SOURCES_NAME, string.Empty, SPListTemplateType.GenericList);
SPList sourceList = currentWeb.Lists.TryGetList(SponsoringCommon.Constants.LISTNAMES_SOURCES_NAME);
SPField titleField = sourceList.Fields.GetField("Title");
titleField.Required = false;
titleField.ShowInEditForm = false;
titleField.ShowInDisplayForm = false;
titleField.ShowInNewForm = false;
titleField.Hidden = true;
titleField.Update();
#endregion
I cannot see the rest of the code, but I had similar problem, and the thing I was missing is to .Update()
the List and the Web. 我看不到其余的代码,但是我遇到了类似的问题,而我所缺少的是对列表和Web进行
.Update()
。 So in your case try to update sourceList and at the end currentWeb . 因此,在您的情况下,请尝试更新sourceList并最后更新currentWeb 。
Hopefully, it will help solve your problem. 希望它将帮助您解决问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.