コード例 #1
0
    protected void AddRegionClick(object sender, EventArgs e)
    {
        Region newRegion = new Region();

        newRegion.Name = popAddRegion.Value;

        newRegion.ParentRegion = SiteManager.GetRegionById(popAddRegion.ReferrerId);
        IList <RegionType> regionTypes = SiteManager.GetAllRegionTypes();
        RegionType         regionType  = regionTypes.Last();

        newRegion.RegionType = regionType;
        if (!SiteManager.IsRegionUnique(newRegion))
        {
            ((IFeedback)this.Page.Master).SetError(GetType(), "The region is not unique within its parent region");
            return;
        }
        SiteManager.CreateRegion(newRegion);

        PopulateTreeView <Region>(SiteManager.GetAllRegions(), true, false, string.Empty);
        RadTreeView1.DataBind();

        RadTreeView1.FindNodeByText(newRegion.Name).ExpandParentNodes();
        RadTreeView1.FindNodeByText(newRegion.ParentRegion.Name).Selected = true;

        ((IFeedback)this.Page.Master).ShowFeedback(
            BusiBlocksConstants.Blocks.Administration.LongName,
            newRegion.GetType().Name,
            Feedback.Actions.Created,
            newRegion.Name
            );
    }