[CLOSED] Creating Custom Control From Ext.Net.Label in MVC 4.0

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    [CLOSED] Creating Custom Control From Ext.Net.Label in MVC 4.0

    Hi,
    I am trying to create custom properties in a custom control derived from Ext.Net.Label. I am able to create a custom control and able to access the inherent properties of Ext.NET, But when I try to add a new property(LabelText) in the derived class like @Html.Y().ExtLabel().LabelText("Hello")
    , it's not showing up on the extension method. Here is the code.

    Derived Class:

    namespace Ext.Net.Extn.Extensions
    {
        public partial class ExtLabel : Label
        {
            public ExtLabel() : base() { }
            
            private string _LabelText;
    
            //Custom Property
            public string LabelText
            {
                get { return _LabelText; }
                set { _LabelText = value; }
            }
        }
    
        public partial class ExtLabel 
        {
            
            //public Builder ToBuilder()
            //{
            //    return new ControlFactory().ExtLabel();
            //}
    
            public class Builder : Builder<ExtLabel, Builder>
            {
                public Builder(ExtLabel label) : base(label) { }
                //public Builder() : base(new ExtLabel()) { }
            }
        }
    }
    Extension: For accessing custom control under Y() extention
    public class Y { }
            public static class YExtensions 
            { 
                public static ControlFactory Y(this HtmlHelper helper) 
                { 
                    return new ControlFactory { HtmlHelper = helper }; 
                } 
            }
    ControlFactory: For creating Builder class of tghe custom control
    public ExtLabel.Builder ExtLabel()
            {
                return BuildControl<ExtLabel, ExtLabel.Builder>(new ExtLabel
                {
                    ID = Guid.NewGuid().ToString("N"),
                    ViewContext = HtmlHelper != null ? HtmlHelper.ViewContext : null
                });
            }
    Factory: Generic method for actually creating the builder class.
    public HtmlHelper _HtmlHelper { get; set; }
    
            public TBuilder BuildControl<TControl, TBuilder>(TControl control)
            {
                return (TBuilder)Activator.CreateInstance(typeof(TBuilder), control);
            }
    The above aproach is working fine for
    Last edited by Baidaly; Jun 12, 2013 at 6:06 PM. Reason: [CLOSED]

Similar Threads

  1. [CLOSED] Ext.net.Label: creating with xtype
    By supera in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Oct 16, 2012, 5:53 PM
  2. [CLOSED] Creating custom control on server side
    By AnulekhaK in forum 1.x Legacy Premium Help
    Replies: 11
    Last Post: Feb 21, 2012, 10:15 AM
  3. [CLOSED] Creating custom control
    By jchau in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Dec 29, 2010, 6:03 PM
  4. [CLOSED] creating a custom class?
    By smmille1 in forum 1.x Legacy Premium Help
    Replies: 10
    Last Post: Jul 09, 2010, 9:31 PM
  5. [CLOSED] First steps creating ext:Label derived control
    By dlouwers in forum 1.x Legacy Premium Help
    Replies: 9
    Last Post: Jan 20, 2009, 12:35 PM

Tags for this Thread

Posting Permissions