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!

  • 相关阅读:
    psy & vr
    psy 2
    psy
    linux c中select使用技巧
    hostent h_addr_list
    gethostbyname() -- 用域名或主机名获取IP地址
    c_select 调用参数说明
    [NYOJ 737] 石子合并(一)
    [HDU 1059] Dividing
    [HDU 1789] Doing Homework again
  • 原文地址:https://www.cnblogs.com/icedog/p/1898969.html
Copyright © 2011-2022 走看看