protected void Page_Load(object sender, EventArgs e)
        {
            string queryString        = Attributes["sc_parameters"];
            NameValueCollection param = Sitecore.Web.WebUtil.ParseUrlParameters(queryString);

            if (!string.IsNullOrEmpty(queryString))
            {
                if (!string.IsNullOrEmpty(param["Web"]))
                {
                    this.Web = param["Web"];
                }

                if (!string.IsNullOrEmpty(param["Server"]))
                {
                    this.ServerUrl = param["Server"];
                }

                if (!string.IsNullOrEmpty(param["SharepointServerType"]))
                {
                    this.SharepointServerType = param["SharepointServerType"];
                }
            }

            if (string.IsNullOrEmpty(this.Web))
            {
                this.Web = SharepointUtils.CurrentWebPath;
            }

            if (string.IsNullOrEmpty(this.ServerUrl))
            {
                ServerUrl = SharepointUtils.CurrentSharepointServer;
            }

            this.SpContext = SpContextProviderBase.Instance.CreateUIContext(this.ServerUrl, this.Web);
            NetworkCredential headerCredential = SharepointExtension.GetCredentialsFromHeader(Request);

            if (headerCredential != null)
            {
                SpContext.Credentials = headerCredential;
            }

            if (!string.IsNullOrEmpty(queryString) && string.IsNullOrEmpty(this.ListName) && !string.IsNullOrEmpty(param["List"]))
            {
                var list = ObjectModel.Entities.Lists.BaseList.GetList(SpContext.Url, param["List"], SpContext);
                if (list != null)
                {
                    this.ListName = list is ObjectModel.Entities.Lists.List ? "Lists/" + list.Name : list.Name;
                }
            }
        }
        protected void Initialize()
        {
            string queryString = Attributes["sc_parameters"];

            if (!string.IsNullOrEmpty(queryString))
            {
                NameValueCollection param = Sitecore.Web.WebUtil.ParseUrlParameters(queryString);
                if (string.IsNullOrEmpty(this.Web))
                {
                    if (string.IsNullOrEmpty(param["Web"]) && string.IsNullOrEmpty(param["Server"]))
                    {
                        this.Web = SharepointUtils.CurrentWebPath;
                    }
                    else
                    {
                        this.Web = param["Web"];
                    }
                }

                if (!string.IsNullOrEmpty(param["Server"]))
                {
                    this.Server = param["Server"];
                }

                if (string.IsNullOrEmpty(this.ListName))
                {
                    this.ListName = param["List"];
                    this.ListName = this.ListName.Replace("%2b", " ");
                    this.ListName = this.ListName.Replace("+", " ");
                }

                this.ShowIfEmpty = MainUtil.GetBool(param["ShowIfEmpty"], false);
            }

            this.context = SpContextProviderBase.Instance.CreateUIContext(this.Server, this.Web);
            NetworkCredential headerCredential = SharepointExtension.GetCredentialsFromHeader(Request);

            if (headerCredential != null)
            {
                this.context.Credentials = headerCredential;
            }
        }