zoukankan      html  css  js  c++  java
  • web properity

    string employeeProfile = GetWebProperty("EmployeeProfileUserGroup");

    SetWebProperty("EmployeeProfileUserGroup", pe.DisplayText);

    static string GetWebProperty(string Name)
    {
     using (SPSite site = new SPSite(SPContext.Current.Site.ID))
     {
      SPWeb web = site.OpenWeb(SPContext.Current.Web.ID);
      if (web.Properties[Name] == null)
      {
       web.AllowUnsafeUpdates = true;
       web.Properties.Add(Name, "");
       web.Properties.Update();
       web.AllowUnsafeUpdates = false;
       return "";
      }
      else
      {
       return web.Properties[Name].ToString();
      }
     }
    }
    void SetWebProperty(string Name, string Value)
    {
     using (SPSite site = new SPSite(SPContext.Current.Site.ID))
     {
      SPWeb web = site.OpenWeb(SPContext.Current.Web.ID);
      GetWebProperty(Name); //ensure the property exists
      web.AllowUnsafeUpdates = true;
      web.Properties[Name] = Value;
      web.Properties.Update();
      web.AllowUnsafeUpdates = false;
     }
    }

    If you would like to share the same properties across multiple webs, use the Site.RootWeb object and store all properties there!

  • 相关阅读:
    【数据结构】Trie(字典树、前缀树)
    【数据结构】优先队列
    【数据结构】堆
    【数据结构】二分搜索树
    【数据结构】哈希表
    【数据结构】链表
    【数据结构】队列
    Python项目案例开发从入门到实战
    Matlab
    Matlab
  • 原文地址:https://www.cnblogs.com/icedog/p/1898969.html
Copyright © 2011-2022 走看看