[CLOSED] Mapping custom properties from EXT ASP.NET controls to ExtJS controls is not working

  1. #1

    [CLOSED] Mapping custom properties from EXT ASP.NET controls to ExtJS controls is not working

    Hi All,

    I am using Ext.NET 2.5.3 release and found that such construction doesn't work anymore:

    <ext:Button runat="server" Text="Filter" Icon="Magnifier" Id="statusFilter" MyCustomProp="1" />
    in js-code, I could use it after all as
    if (Ext.getCmp('statusFilter').myCustomProp == "1") {
    .....
    }
    Now I see that all my properties defined like this are ignored and corresponding properties for ExtJS are not creating. Is this a bug or behaviour was changed since 2.5.1?

    Alexander
    Last edited by Daniil; Jan 05, 2015 at 1:59 PM. Reason: Please use [CODE] tags, [CLOSED]
  2. #2
    Can you please double check? The following is working in 2.5.3:

    <%@ Page Language="C#" %>
    
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" />
            <ext:Button runat="server" Text="Filter" Icon="Magnifier" Id="statusFilter" MyCustomProp="111">
                <Listeners>
                    <Click Handler="alert(Ext.getCmp('statusFilter').myCustomProp);" />
                </Listeners>
            </ext:Button>
    
        </form>
    </body>
    </html>
  3. #3
    Hi Mimisss,

    Yes, I've checked and found that it works in your case. However if you try to do it using ToConfig this doesn't work. For instance, like this:
    string str = ComponentLoader.ToConfig("<ext:Button runat=\"server\" Text=\"Filter\" Icon=\"Magnifier\" Id=\"statusFilter\" MyCustomProp=\"1\" />")
    Honestly, now I am not sure, did it work before like this in my application because I did a lot of changes :-)

    Alexander
  4. #4
    Hi Alexander,

    If you define some custom property in markup, it is a shorthand for a control's CustomConfig. In code behind you cannot just define a non-existing property, so, you have to use a CustomConfig.

    A .ToConfig() call appears to be working correctly with a CustomConfig.

    Example
    <%@ Page Language="C#" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                var btn = new Ext.Net.Button();
                btn.CustomConfig.Add(new ConfigItem("customProp", "customPropValue"));
                X.Msg.Alert(".ToConfig()", ComponentLoader.ToConfig(btn)).Show();
            }
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
        </form>
    </body>
    </html>
    Last edited by Daniil; Jan 05, 2015 at 1:39 PM.
  5. #5
    Hi Daniil,

    You example works but I have a bit different aspect. First of all, I think it is only related with GridPanel, because with other controls seems it is working fine. Here is detailed steps how to reproduce it:

    1) Create a simple control and place GridPanel inside of it. Also define custom properties directly in ASPX code:
    <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" ClientIDMode="Static" %>
    
    <ext:GridPanel Frame="true" Layout="Fit" runat="server" MyCustomProp="1">
        <Buttons>
          <ext:Button runat="server" Text="Ok" MyCustomProp="2" />
          <ext:Button runat="server" Text="Cancel" MyCustomProp="3" />
        </Buttons>
    </ext:GridPanel>
    2) Write a simple controller that will load this control and generate control's config like this:
            public string TestController()
            {
                ViewUserControl uc1 = (ViewUserControl)UserControlRenderer.LoadControl("~/Views/Shared/test.ascx");
                string str = ComponentLoader.ToConfig(uc1);
                return str;
            }
    3) The controller will return you the following string:
    [{"frame":true,"xtype":"grid","layout":"fit","buttons":[{"text":"Ok"},{"text":"Cancel"}],"columns":{}}]
    As you see in the results you can't find any mention about MyCustomProp. However for the following control:

    <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" ClientIDMode="Static" %>
    
    <ext:Panel Frame="true" Layout="Fit" runat="server" MyCustomProp="1">
        <Buttons>
          <ext:Button runat="server" Text="Ok" MyCustomProp="2" />
          <ext:Button runat="server" Text="Cancel" MyCustomProp="3" />
        </Buttons>
    </ext:Panel>
    the results will be completely different:

    [{myCustomProp:1,frame:true,xtype:"panel",layout:"fit",buttons:[{myCustomProp:2,text:"Ok"},{myCustomProp:3,text:"Cancel"}]}]
    Can you explain why this is not working in case of GridPanel?

    Thanks,
    Alexander
  6. #6
    That is a defect. Thank you for the report!

    Created an Issue.
    https://github.com/extnet/Ext.NET/issues/628

    It has been fixed:
    v2: revision 6240 (branches/2). It goes to v2.5.4.
    v3: revision 6241 (trunk). It goes to v3.1.

Similar Threads

  1. Razor: Custom Controls: 2 Controls as 1
    By bright in forum 2.x Help
    Replies: 0
    Last Post: Nov 09, 2013, 11:42 AM
  2. [CLOSED] V2 events and properties list for controls.
    By alscg in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Jan 08, 2013, 11:29 AM
  3. Doubt regarding ExtJS.Net and Asp.Net controls
    By praveencat123 in forum 1.x Help
    Replies: 2
    Last Post: Oct 13, 2012, 10:35 AM
  4. Replies: 1
    Last Post: Jul 20, 2012, 8:08 AM
  5. EXTJS combined with Coolite Controls
    By simbal in forum 1.x Help
    Replies: 2
    Last Post: Apr 05, 2009, 5:55 PM

Posting Permissions