Ejemplo n.º 1
0
        private void InitByPath()
        {
            if (this.uc == null && this.Path.IsNotEmpty())
            {
                if (this.Page != null)
                {
                    var path = this.Path;
                    if (!path.StartsWith("~") && !path.StartsWith("/") && HttpContext.Current != null && HttpContext.Current.CurrentHandler is System.Web.UI.Page)
                    {
                        var dir = System.IO.Path.GetDirectoryName(HttpContext.Current.Request.CurrentExecutionFilePath).Replace("\\", "/");
                        path = dir + "/" + path;
                    }

                    this.uc = (UserControl)this.Page.LoadControl(path);

                    if (this.UserControlID.IsNotEmpty())
                    {
                        this.uc.ID = this.UserControlID;
                    }
#if NET40
                    this.uc.ClientIDMode = this.UserControlClientIDMode;
#endif
                    this.AfterUCAdd(this.uc);
                }
                else
                {
                    this.uc = UserControlRenderer.LoadControl(this.Path, this.UserControlID.IsNotEmpty() ? this.UserControlID : null);
#if NET40
                    this.uc.ClientIDMode = this.UserControlClientIDMode;
#endif
                }
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="config"></param>
        /// <returns></returns>
        public virtual string Build(UserControlRendrerConfig config)
        {
            string      id = config.UserControlId ?? BaseControl.GenerateId();
            UserControl uc = UserControlRenderer.LoadControl(config.UserControlPath, id);

            uc.ClientIDMode = config.UserControlClientIDMode;
            Page pageHolder = uc.Page;

            BaseControl controlToRender = null;

            if (config.ControlIdToRender.IsEmpty() && !config.SingleControl)
            {
                Container ct = new Container {
                    ID = id + "_ct", IDMode = IDMode.Static
                };
                pageHolder.Controls.Add(ct);
                ct.ContentControls.Add(uc);
                controlToRender = ct;
            }
            else
            {
                pageHolder.Controls.Add(uc);
                BaseControl c;

                if (config.SingleControl)
                {
                    c = Ext.Net.Utilities.ControlUtils.FindControl <BaseControl>(uc);
                }
                else
                {
                    c = Ext.Net.Utilities.ControlUtils.FindControl <BaseControl>(pageHolder, config.ControlIdToRender);
                }

                if (c == null)
                {
                    if (config.SingleControl)
                    {
                        throw new Exception("Cannot find the Ext.Net control in the view");
                    }
                    else
                    {
                        throw new Exception("Cannot find the control with ID=" + config.ControlIdToRender);
                    }
                }

                controlToRender = c;

                if (!controlToRender.HasOwnIDMode)
                {
                    controlToRender.IDMode = IDMode.Static;
                }
            }

            config.OnBeforeRender(new ComponentAddedEventArgs(controlToRender));

            return(config.Index.HasValue ? controlToRender.ToScript(config.Mode, config.Element, config.Index.Value, true) : controlToRender.ToScript(config.Mode, config.Element, true));
        }
Ejemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="userControlPath"></param>
        /// <param name="controlIdToRender"></param>
        /// <param name="mode"></param>
        /// <param name="element"></param>
        /// <param name="index"></param>
        /// <returns></returns>
        public virtual string Build(string userControlPath, string controlIdToRender, RenderMode mode, string element, int?index)
        {
            string      id         = "ID_" + Guid.NewGuid().ToString().Replace("-", "");
            UserControl uc         = UserControlRenderer.LoadControl(userControlPath, id);
            Page        pageHolder = uc.Page;

            XControl controlToRender = null;

            if (controlIdToRender.IsEmpty())
            {
                Container ct = new Container {
                    ID = id, IDMode = IDMode.Explicit
                };
                pageHolder.Controls.Add(ct);
                ct.ContentControls.Add(uc);
                controlToRender = ct;
            }
            else
            {
                pageHolder.Controls.Add(uc);
                XControl c = Ext.Net.Utilities.ControlUtils.FindControl <XControl>(pageHolder, controlIdToRender);
                if (c == null)
                {
                    throw new Exception("Cannot find the control with ID=" + controlIdToRender);
                }

                controlToRender = c;

                if (controlToRender.IDMode == IDMode.Inherit)
                {
                    controlToRender.IDMode = IDMode.Explicit;
                }
            }

            return(index.HasValue ? controlToRender.ToScript(mode, element, index.Value, true) : controlToRender.ToScript(mode, element, true));
        }
Ejemplo n.º 4
0
 public static string ToConfig(string path, string userControlId, Ext.Net.UserControlLoader.ComponentAddedEventHandler componentPreRender, bool registerResources)
 {
     return(ComponentLoader.ToConfig(UserControlRenderer.LoadControl(path, userControlId), componentPreRender, registerResources));
 }
Ejemplo n.º 5
0
 public static string ToConfig(string path, string userControlId, bool registerResources)
 {
     return(ComponentLoader.ToConfig(UserControlRenderer.LoadControl(path, userControlId), registerResources));
 }
Ejemplo n.º 6
0
 public static string ToConfig(string path, string userControlId)
 {
     return(ComponentLoader.ToConfig(UserControlRenderer.LoadControl(path, userControlId)));
 }
Ejemplo n.º 7
0
 public static void Render(string path, string userControlId, Ext.Net.UserControlLoader.ComponentAddedEventHandler componentPreRender, bool registerResources)
 {
     ComponentLoader.Render(UserControlRenderer.LoadControl(path, userControlId), componentPreRender, registerResources);
 }
Ejemplo n.º 8
0
 public static void Render(string path, string userControlId, bool registerResources)
 {
     ComponentLoader.Render(UserControlRenderer.LoadControl(path, userControlId), registerResources);
 }
Ejemplo n.º 9
0
 public static void Render(string path, string userControlId)
 {
     ComponentLoader.Render(UserControlRenderer.LoadControl(path, userControlId));
 }
Ejemplo n.º 10
0
 public static string ToConfig(string path, Ext.Net.UserControlLoader.ComponentAddedEventHandler componentPreRender)
 {
     return(ComponentLoader.ToConfig(UserControlRenderer.LoadControl(path), componentPreRender));
 }
Ejemplo n.º 11
0
 public static void Render(string path, Ext.Net.UserControlLoader.ComponentAddedEventHandler componentPreRender)
 {
     ComponentLoader.Render(UserControlRenderer.LoadControl(path), componentPreRender);
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="userControlPath"></param>
 /// <param name="id"></param>
 /// <returns></returns>
 public static UserControl LoadControl(string userControlPath, string id)
 {
     return(UserControlRenderer.LoadControl <SelfRenderingPage>(userControlPath, id));
 }
 /// <summary>
 ///
 /// </summary>
 /// <typeparam name="Page"></typeparam>
 /// <param name="userControlPath"></param>
 /// <returns></returns>
 public static UserControl LoadControl <Page>(string userControlPath) where Page : System.Web.UI.Page, ISelfRenderingPage, new()
 {
     return(UserControlRenderer.LoadControl <Page>(userControlPath, null));
 }
Ejemplo n.º 14
0
 public static string ToJson(string path)
 {
     return(ComponentLoader.ToJson(UserControlRenderer.LoadControl(path)));
 }