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!

  • 相关阅读:
    c#多线程和Socket笔记
    Socket测试工具包的开发(TCP UDP)
    使用socket模拟服务器给客户端发消息
    AU3学习笔记
    c#委托与事件(三)
    c#委托与事件(二)
    使用的工具
    Zip 压缩问题件,获取真实扩展名
    PsExec使用
    socket 통신
  • 原文地址:https://www.cnblogs.com/icedog/p/1898969.html
Copyright © 2011-2022 走看看