コード例 #1
0
        protected void PolicyAreasTreeView_NodeCheck(object sender, RadTreeNodeEventArgs e)
        {
            if (e.Node.CheckState == TreeNodeCheckState.Checked)
            {
                var currentUri = this.Page.Request.Url;

                var values = new Dictionary <string, string> {
                    { e.Node.Attributes["queryStringKey"], "on" }
                };
                var redirectLocation = currentUri.ExtendQuery(values).AbsoluteUri;

                if (e.Node.Text == "All Policy Areas")
                {
                    this.PolicyAreasTreeView.UncheckAllNodes();
                    e.Node.Checked   = true;
                    redirectLocation = String.Format("{0}{1}{2}{3}", currentUri.Scheme, Uri.SchemeDelimiter,
                                                     currentUri.Authority, currentUri.AbsolutePath);
                }
                else
                {
                    var allPolicyAreas = this.PolicyAreasTreeView.FindNodeByText("All Policy Areas");
                    if (allPolicyAreas != null)
                    {
                        allPolicyAreas.Checked = false;
                    }
                }

                HttpContext.Current.Response.Redirect(redirectLocation);
            }
            else
            {
                var currentUri                  = this.Page.Request.Url;
                var redirectLocation            = currentUri.AbsoluteUri;
                NameValueCollection queryString = new NameValueCollection(this.Page.Request.QueryString);
                if (queryString.Count != 0)
                {
                    queryString.Remove(e.Node.Attributes["queryStringKey"]);
                    if (queryString.Count > 0)
                    {
                        redirectLocation = currentUri.AbsolutePath + "?" + UriExtensions.ConstructQueryString(queryString);
                    }
                    else
                    {
                        redirectLocation = currentUri.AbsolutePath;
                    }
                }

                HttpContext.Current.Response.Redirect(redirectLocation);
            }
        }