[CLOSED] Custom attribute on all controls

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] Custom attribute on all controls

    Hi guys,
    I'm wondering if there is any plan of adding a custom attribute to all controls, e.g. "customAttr", that we can populate with anything value we want. I know we have custom configs but the ability to have an attribute of say:

     <ext:Column runat="server" customAttr="myvalue" Text="Property" DataIndex="PropertyDescription" Flex="2">
    would be very beneficial without having to declare a custom config. And if we could comma separate values and a string array get returned would be even better.

    Obviously in ASP.NET you can add as many attributes you want to a control without it throwing an exception, but we can't do this in Ext.NET. It seems it would be an easy thing to implement by adding a string property on the "abstractcomponent" (I think it's this class) in the codebase or will wil have to do this ourselves?

    Your thoughts on this would be much appreciated.
    Kev
    Last edited by Daniil; Dec 18, 2012 at 11:22 AM. Reason: [CLOSED]
  2. #2
    This should work now. I'll have to run a test to confirm.
    Geoffrey McGill
    Founder
  3. #3
    Hi Kev,

    Thank you for the suggestion, but it is already presented in Ext.NET.

    Example
    <%@ Page Language="C#" %>
     
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <ext:ResourceManager runat="server" />
    
        <ext:Button 
            runat="server" 
            CustomProperty="Hello!" 
            Text="Click me" 
            Handler="alert(this.customProperty);" />
    </body>
    </html>
    Any non existing properties will go to the control's CustomConfig collection. This functionality is available for the majority of the Ext.NET things.

    To get a JavaScript array as a value you can use a special ={} syntax. This syntax causes a value to be rendered in Raw mode.
    CustomProperty="={[1,2]}"
    Please note that the first letter is rendered lowercase to meet the JavaScript naming convention.

    In some rare cases it might need to override some existing property. For instance,
    <ext:Panel runat="server" Collapsible="false" />
    The Collapsibe="false" is not rendered because false is by default.

    Imagine, that you somehow need to get it rendered. Please prefix the property with "X".
    <ext:Panel runat="server" XCollapsible="false" />
  4. #4
    Quote Originally Posted by Daniil View Post
    Hi Kev,

    Thank you for the suggestion, but it is already presented in Ext.NET.

    Example
    <%@ Page Language="C#" %>
     
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <ext:ResourceManager runat="server" />
    
        <ext:Button 
            runat="server" 
            CustomProperty="Hello!" 
            Text="Click me" 
            Handler="alert(this.customProperty);" />
    </body>
    </html>
    Any non existing properties will go to the control's CustomConfig collection. This functionality is available for the majority of the Ext.NET things.

    To get a JavaScript array as a value you can use a special ={} syntax. This syntax causes a value to be rendered in Raw mode.
    CustomProperty="={[1,2]}"
    Please note that the first letter is rendered lowercase to meet the JavaScript naming convention.

    In some rare cases it might need to override some existing property. For instance,
    <ext:Panel runat="server" Collapsible="false" />
    The Collapsibe="false" is not rendered because false is by default.

    Imagine, that you somehow need to get it rendered. Please prefix the property with "X".
    <ext:Panel runat="server" XCollapsible="false" />
    Hi Daniil,
    I need to access it server side and what you suggested doesn't work on the server unfortunately. Would Geoffrey's fix still be ok to put in?
  5. #5
    Quote Originally Posted by geoffrey.mcgill View Post
    This should work now. I'll have to run a test to confirm.
    Hi Geoffrey, did you have any success on the testing of this?
    Kev
  6. #6
    You can use the Tag and TagString property. But there is some problem. We are investigating.
  7. #7
    Quote Originally Posted by Daniil View Post
    You can use the Tag and TagString property. But there is some problem. We are investigating.
    There is a problem if a value is a string. I think we will fix it shortly.

    But everything is okay with an object.

    Example
    <%@ Page Language="C#" %>
     
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                this.Button1.Tag = new
                {
                    message = "Hello!"
                };
            }
        }
    
        protected void GetTag(object sender, DirectEventArgs e)
        {
            X.Msg.Alert("Server", (sender as Ext.Net.Button).TagString).Show();
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <ext:Button 
                ID="Button1"
                runat="server" 
                Text="Test" 
                Handler="alert('client: ' + this.tag);"
                OnDirectClick="GetTag" />
        </form>
    </body>
    </html>
  8. #8
    Quote Originally Posted by Daniil View Post
    There is a problem if a value is a string. I think we will fix it shortly.
    Here is a sample to reproduce the problem. An exception occurs during a DirectEvent.

    Example
    <%@ Page Language="C#" %>
     
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void GetTag(object sender, DirectEventArgs e)
        {
            X.Msg.Alert("Server", (sender as Ext.Net.Button).TagString).Show();
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <ext:Button 
                ID="Button1"
                runat="server" 
                TagString="Hello!"
                Text="Test" 
                Handler="alert('client: ' + this.tag);"
                OnDirectClick="GetTag" />
        </form>
    </body>
    </html>
  9. #9
    Quote Originally Posted by Daniil View Post
    You can use the Tag and TagString property. But there is some problem. We are investigating.
    Ok, thank you. It looks as though it's the same problem as setting the empty value property on a NumberField, as it's declared as an Object. You can do it fine in the code behind but not in markup.
  10. #10
    Quote Originally Posted by Kev View Post
    Ok, thank you. It looks as though it's the same problem as setting the empty value property on a NumberField, as it's declared as an Object. You can do it fine in the code behind but not in markup.
    Do you know any solution for this issue? We would be happy to implement.

    It is possible to declare a string value using the TagString property.
Page 1 of 2 12 LastLast

Similar Threads

  1. Custom Controls In Tabs
    By zeus in forum 1.x Help
    Replies: 8
    Last Post: Apr 02, 2012, 3:34 PM
  2. Custom CSS for Ext.Net controls
    By huzzy143 in forum 1.x Help
    Replies: 0
    Last Post: Oct 12, 2011, 6:19 PM
  3. [CLOSED] Adding custom html attribute
    By SymSure in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Aug 30, 2011, 12:25 AM
  4. Custom controls
    By felipevn in forum 1.x Help
    Replies: 2
    Last Post: Jul 18, 2011, 10:53 PM
  5. [CLOSED] Get parent node custom attribute
    By jmcantrell in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jul 14, 2010, 9:19 PM

Tags for this Thread

Posting Permissions