public AjaxControlToolkit.CascadingDropDownNameValue[] GetDropDownContainerValues(string knownCategoryValues, string category)
        {
            StringDictionary knownCategoryValuesDictionary = AjaxControlToolkit.CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);

            int CMSControlID = 0;
            int.TryParse(knownCategoryValuesDictionary["CMSControls"], out CMSControlID);

            List<AjaxControlToolkit.CascadingDropDownNameValue> cascadingList = new List<AjaxControlToolkit.CascadingDropDownNameValue>();
            CMSControl cmsControl = CMSControlManager.GetCMSControl(CMSControlID);
            if (cmsControl != null)
            {
                try
                {
                    System.Web.UI.Page page = new System.Web.UI.Page();
                    CMSUserControlBase userControl = page.LoadControl(cmsControl.UserControlPath) as CMSUserControlBase;
                    if (userControl != null)
                    {
                        Dictionary<string, string> itemsControl = userControl.GetContainerValue(cmsControl.ModuleID, CMSContext.PortalID, CMSContext.LanguageID);
                        foreach (KeyValuePair<string, string> itemControl in itemsControl)
                        {
                            cascadingList.Add(new AjaxControlToolkit.CascadingDropDownNameValue(itemControl.Value, itemControl.Key));
                        }
                    }
                }
                catch (Exception ex)
                {
                    cascadingList.Add(new AjaxControlToolkit.CascadingDropDownNameValue(ex.Message, "0"));
                }
            }
            return cascadingList.ToArray();
        }
Exemplo n.º 2
0
        public override void Packaging(Item item)
        {
            List <string> _temp = new List <string>();

            foreach (var file in item.Resources.Where(x => x.PackageFromPath.ToLower().EndsWith(".ascx")))
            {
                string ascx        = file.PackageFromPath;
                string ascx_mapped = Context.Current.MapPath(ascx);

                //item.Resources.Add(ascx);

                try
                {
                    if (System.IO.File.Exists(ascx_mapped + ".cs"))
                    {
                        _temp.Add(ascx + ".cs");
                    }

                    if (System.IO.File.Exists(ascx_mapped + ".designer.cs"))
                    {
                        _temp.Add(ascx + ".designer.cs");
                    }


                    System.Web.UI.Page p = new System.Web.UI.Page();

                    if (p != null)
                    {
                        var c = p.LoadControl(ascx);

                        if (c != null)
                        {
                            string ass = c.GetType().Assembly.GetName().Name;
                            string dll = "~/bin/" + ass + ".dll";

                            if (System.IO.File.Exists(Context.Current.MapPath(dll)))
                            {
                                _temp.Add(dll);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    RevisionLog.Instance.Error(item, this, RevisionLog.ItemDataResolvers, ex.ToString());
                }
            }

            foreach (var s in _temp)
            {
                item.Resources.Add(s);
            }
        }
Exemplo n.º 3
0
        private static System.Web.UI.Control LoadSingleControl(string blockName, ref System.Web.UI.Page p)
        {
            System.Web.UI.Control result = null;

            if (p != null)
            {
                string controlName = p.Request.PhysicalApplicationPath;
                controlName = Path.Combine(controlName, blockName);
                if (File.Exists(controlName))
                {
                    string virtualPath = "~/" + blockName.Replace("\\", "/");
                    result = p.LoadControl(virtualPath);
                }
            }

            return(result);
        }
Exemplo n.º 4
0
        public void ProcessRequest(HttpContext context)
        {
            if (!Global.IdUser.HasValue)
            {
                context.Response.Write("ERROR_SESSION");
                return;
            }

            System.Web.UI.Page        pageHolder  = new System.Web.UI.Page();
            System.Web.UI.UserControl viewControl = (System.Web.UI.UserControl)pageHolder.LoadControl(context.Request.Params["Page"]);

            pageHolder.Controls.Add(viewControl);
            StringWriter result = new StringWriter();

            HttpContext.Current.Server.Execute(pageHolder, result, false);
            context.Response.Write(result.ToString());
        }
        public string GetSideCart(bool showButton)
        {
            System.Web.UI.Page page = new System.Web.UI.Page();
            WebUserControl1 ctl =
              (WebUserControl1)page.LoadControl("~/WebUserControl1.ascx");
            page.Controls.Add(ctl);

            System.IO.StringWriter writer = new System.IO.StringWriter();
            try
            {
                HttpContext.Current.Server.Execute(page, writer, false);
                page.Dispose();
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message + " " + ex.StackTrace);
            }
            return writer.ToString();
        }
        public void UserControlIsBuiltUpOnInit()
        {
            MockWebClientApplication application = new MockWebClientApplication();
            MockHttpContext          mockContext = new MockHttpContext();

            mockContext.Request             = new HttpRequest("page.aspx", "http://application/page.aspx", null);
            mockContext.ApplicationInstance = application;
            application.SetTestCurrentContext(mockContext);
            System.Web.UI.Page page = new System.Web.UI.Page();
            MockUserControl    uc   = (MockUserControl)page.LoadControl(typeof(MockUserControl), null);

            page.Controls.Add(uc);

            Assert.IsFalse(uc.OnBuiltUpCalled);

            uc.FireOnInit();

            Assert.IsTrue(uc.OnBuiltUpCalled);
        }
Exemplo n.º 7
0
        public static string RenderPagerHTML(string usercontrolPath, UserControls.PagerData pager, int totalCount)
        {
            System.Web.UI.Page page    = new System.Web.UI.Page();
            UserControls.Pager ucPager = (UserControls.Pager)page.LoadControl(usercontrolPath + "/Pager.ascx");
            System.Web.UI.HtmlControls.HtmlForm form = new System.Web.UI.HtmlControls.HtmlForm();
            if (ucPager != null)
            {
                ucPager.CurrentPage  = pager.CurrentPage;
                ucPager.PageSize     = pager.PageSize;
                ucPager.RowCount     = totalCount;
                ucPager.AllowPaging  = false;
                ucPager.SelectMethod = pager.SelectMethod;
                ucPager.doPaging();
                form.Controls.Add(ucPager);
            }
            page.Controls.Add(form);
            foreach (System.Web.UI.Control ctrlpage in page.Controls)
            {
                foreach (System.Web.UI.Control ctrl in ctrlpage.Controls)
                {
                    UserControls.Pager ucPager1 = ctrl as UserControls.Pager;
                    if (ucPager1 != null)
                    {
                        ucPager1.BindControls(pager);
                        break;
                    }
                }
            }

            StringWriter textWriter = new StringWriter();

            HttpContext.Current.Server.Execute(page, textWriter, false);
            string htmlData = CleanHtml(textWriter.ToString());

            textWriter.Close();
            return(htmlData);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Registers any block types that are not currently registered in Rock.
        /// </summary>
        /// <param name="physWebAppPath">A <see cref="System.String" /> containing the physical path to Rock on the server.</param>
        /// <param name="page">The <see cref="System.Web.UI.Page" />.</param>
        /// <param name="refreshAll">if set to <c>true</c> will refresh name, category, and description for all block types (not just the new ones)</param>
        public static void RegisterBlockTypes( string physWebAppPath, System.Web.UI.Page page, bool refreshAll = false)
        {
            // Dictionary for block types.  Key is path, value is friendly name
            var list = new Dictionary<string, string>();

            // Find all the blocks in the Blocks folder...
            FindAllBlocksInPath( physWebAppPath, list, "Blocks" );

            // Now do the exact same thing for the Plugins folder...
            FindAllBlocksInPath( physWebAppPath, list, "Plugins" );

            // Get a list of the BlockTypes already registered (via the path)
            var rockContext = new RockContext();
            var blockTypeService = new BlockTypeService( rockContext );
            var registered = blockTypeService.Queryable().ToList();

            // for each BlockType
            foreach ( string path in list.Keys)
            {
                if ( refreshAll || !registered.Any( b => b.Path.Equals( path, StringComparison.OrdinalIgnoreCase ) ) )
                {
                    // Attempt to load the control
                    try
                    {
                        System.Web.UI.Control control = page.LoadControl( path );

                        if ( control is Rock.Web.UI.RockBlock )
                        {
                            var blockType = registered.FirstOrDefault( b => b.Path.Equals( path, StringComparison.OrdinalIgnoreCase ) );
                            if ( blockType == null )
                            {
                                // Create new BlockType record and save it
                                blockType = new BlockType();
                                blockType.Path = path;
                                blockTypeService.Add( blockType );
                            }

                            Type controlType = control.GetType();

                            // Update Name, Category, and Description based on block's attribute definitions
                            blockType.Name = Rock.Reflection.GetDisplayName( controlType ) ?? string.Empty;
                            if ( string.IsNullOrWhiteSpace( blockType.Name ) )
                            {
                                // Parse the relative path to get the name
                                var nameParts = list[path].Split( '/' );
                                for ( int i = 0; i < nameParts.Length; i++ )
                                {
                                    if ( i == nameParts.Length - 1 )
                                    {
                                        nameParts[i] = Path.GetFileNameWithoutExtension( nameParts[i] );
                                    }
                                    nameParts[i] = nameParts[i].SplitCase();
                                }
                                blockType.Name = string.Join( " > ", nameParts );
                            }
                            if ( blockType.Name.Length > 100 )
                            {
                                blockType.Name = blockType.Name.Truncate( 100 );
                            }
                            blockType.Category = Rock.Reflection.GetCategory( controlType ) ?? string.Empty;
                            blockType.Description = Rock.Reflection.GetDescription( controlType ) ?? string.Empty;
                        }
                    }
                    catch ( Exception ex )
                    {
                        ExceptionLogService.LogException( new Exception( string.Format("Problem processing block with path '{0}'.", path ), ex ), null );
                    }
                }
            }

            rockContext.SaveChanges();
        
        }
Exemplo n.º 9
0
 public System.Web.UI.Control CreatePropertyControl(System.Web.UI.Page ownerPage)
 {
     return(ownerPage.LoadControl(this.PropertyControlPath));
 }
Exemplo n.º 10
0
        /// <summary>
        /// Registers any block types that are not currently registered in Rock.
        /// </summary>
        /// <param name="physWebAppPath">A <see cref="System.String" /> containing the physical path to Rock on the server.</param>
        /// <param name="page">The <see cref="System.Web.UI.Page" />.</param>
        /// <param name="currentPersonId">A <see cref="System.Int32" /> that contains the Id of the currently logged on <see cref="Rock.Model.Person" />.</param>
        /// <param name="refreshAll">if set to <c>true</c> will refresh name, category, and description for all block types (not just the new ones)</param>
        public void RegisterBlockTypes(string physWebAppPath, System.Web.UI.Page page, int?currentPersonId, bool refreshAll = false)
        {
            // Dictionary for block types.  Key is path, value is friendly name
            var list = new Dictionary <string, string>();

            // Find all the blocks in the Blocks folder...
            FindAllBlocksInPath(physWebAppPath, list, "Blocks");

            // Now do the exact same thing for the Plugins folder...
            FindAllBlocksInPath(physWebAppPath, list, "Plugins");

            // Get a list of the BlockTypes already registered (via the path)
            var registered = Repository.GetAll();

            // for each BlockType
            foreach (string path in list.Keys)
            {
                if (refreshAll || !registered.Any(b => b.Path.Equals(path, StringComparison.OrdinalIgnoreCase)))
                {
                    // Attempt to load the control
                    System.Web.UI.Control control = page.LoadControl(path);
                    if (control is Rock.Web.UI.RockBlock)
                    {
                        var blockType = registered.FirstOrDefault(b => b.Path.Equals(path, StringComparison.OrdinalIgnoreCase));
                        if (blockType == null)
                        {
                            // Create new BlockType record and save it
                            blockType      = new BlockType();
                            blockType.Path = path;
                            blockType.Guid = new Guid();
                            this.Add(blockType, currentPersonId);
                        }

                        Type controlType = control.GetType();

                        // Update Name, Category, and Description based on block's attribute definitions
                        blockType.Name = Rock.Reflection.GetDisplayName(controlType) ?? string.Empty;
                        if (string.IsNullOrWhiteSpace(blockType.Name))
                        {
                            // Parse the relative path to get the name
                            var nameParts = list[path].Split('/');
                            for (int i = 0; i < nameParts.Length; i++)
                            {
                                if (i == nameParts.Length - 1)
                                {
                                    nameParts[i] = Path.GetFileNameWithoutExtension(nameParts[i]);
                                }
                                nameParts[i] = nameParts[i].SplitCase();
                            }
                            blockType.Name = string.Join(" > ", nameParts);
                        }
                        if (blockType.Name.Length > 100)
                        {
                            blockType.Name = blockType.Name.Truncate(100);
                        }
                        blockType.Category    = Rock.Reflection.GetCategory(controlType) ?? string.Empty;
                        blockType.Description = Rock.Reflection.GetDescription(controlType) ?? string.Empty;

                        this.Save(blockType, currentPersonId);
                    }
                }
            }
        }
        public void UserControlIsBuiltUpOnInit()
        {
            MockWebClientApplication application = new MockWebClientApplication();
            MockHttpContext mockContext = new MockHttpContext();
            mockContext.Request = new HttpRequest("page.aspx", "http://application/page.aspx", null);
            mockContext.ApplicationInstance = application;
            application.SetTestCurrentContext(mockContext);
            System.Web.UI.Page page = new System.Web.UI.Page();
            MockUserControl uc = (MockUserControl) page.LoadControl(typeof (MockUserControl), null);
            page.Controls.Add(uc);

            Assert.IsFalse(uc.OnBuiltUpCalled);

            uc.FireOnInit();

            Assert.IsTrue(uc.OnBuiltUpCalled);
        }
 public override IBASEControl CreateControl(System.Web.UI.Page page, string tagName)
 {
     return((IBASEControl)page.LoadControl("~/Modules/" + this._parentDefName + "/" + this._ascxFile));
 }