[CLOSED] First steps creating ext:Label derived control

  1. #1

    [CLOSED] First steps creating ext:Label derived control

    Hi,

    I am now trying to derive a custom control off of ext:Label. I noticed that inside an async callback handler I can easily set the Html attribute of this label derived control. However, I cannot find out where to handle this inside my custom control. Setting this.Html inside of Render does nothing. What method should I override to get a chance to change properties mapping to client methods?

    Best,

    Dirk Louwers
  2. #2

    RE: [CLOSED] First steps creating ext:Label derived control

    Hi Dirk,

    All properties which marked with ClientConfig attribute automatic generate script during AjaxEvent if they were modified.
    You should consider to use*AjaxEventUpdate attribute. It specifies behaivore for script generating.


    If you can provide more details about what you want I can give additional details
    *
  3. #3

    RE: [CLOSED] First steps creating ext:Label derived control

    Hi,

    I have handled it by overriding the OnAfterClientInitHandler and setting Html there. For some reason this didn't work from Render for instance.

    I wanted to make a control that updates it's inner html on postbacks and async callbacks.

    Is OnAfterClientInitHandler the right spot to do so or would you advise another spot?

    Best,

    Dirk Louwers
  4. #4

    RE: [CLOSED] First steps creating ext:Label derived control

    Hi Dirk,

    The best place to add custom logic (postback/async postback) is SweepControls.
    Do you try Html property from Label or you override it in your class?


  5. #5

    RE: [CLOSED] First steps creating ext:Label derived control

    Hi,

    I use the one from Label. Label seemed a very basic control that would be suitable for what I needed. It's basically an img with qtip containing an ul containing validation errors.

    Ideally it would have a method to set errors in an intelligent manner (JSON and client side processing) but changing innerHTML works fine.

    What exactly is the function of the SweepControls method?

    Best,

    Dirk Louwers
  6. #6

    RE: [CLOSED] First steps creating ext:Label derived control

    The SweepControls event is currently the last event in the Control life-cycle where updates to properties are guarenteed to be rendered.

    Please Note: There may be some changes coming to the control life-cycle during the v0.8 build cycle.




    Geoffrey McGill
    Founder
  7. #7

    RE: [CLOSED] First steps creating ext:Label derived control

    Hi,

    Ok, SweepControls works for me too.

    There is just one issue left regarding ViewState. I have two properties named Title and IconSrc. They look like this:

    public string Title
            {
                get
                {
                    var value = ViewState["Title"] as string ?? "";
                    return value;
                }
                set
                {
                    ViewState["Title"] = value;
                }
            }
    
            public string IconSrc
            {
                get
                {
                    var value = ViewState["IconSrc"] as string ?? "";
                    return value;
                }
                set
                {
                    ViewState["IconSrc"] = value;
                }
            }
    I can see the set methods are called. But after a callback the ViewState items evaluate to null. Do Controls have a different way of handling viewstate that I should be aware of?

    Best,

    Dirk Louwers
  8. #8

    RE: [CLOSED] First steps creating ext:Label derived control

    Hi Dirk,

    It's a bit hard to tell exactly what might be going wrong, but the following code is copy/paste from some of our controls and demonstrates how we get/set string values from ViewState.

    If your control inherits from a Coolite Toolkit control, then the following code should work in a similar manner.

    Example

    public virtual string Text
    {
        get
        {
            return (string)this.ViewState["Text"] ?? "";
        }
        set
        {
            this.ViewState["Text"] = value;
        }
    }
    
    public virtual string IconCls
    {
        get
        {
            return (string)this.ViewState["IconCls"] ?? "";
        }
        set
        {
            this.ViewState["IconCls"] = value;
        }
    }
    Hope this helps.

    Geoffrey McGill
    Founder
  9. #9

    RE: [CLOSED] First steps creating ext:Label derived control

    Another thing to note, by default ViewState is not sent during an AjaxEvent. You can include ViewState during the AjaxEvent by setting ViewStateMode="Include" on the AjaxEvent config property.

    Example

    <ext:Button ID="Button1" runat="server" Text="Click Me!">
        <AjaxEvents>
            <Click OnEvent="Button1_Click" ViewStateMode="Include" />
        </AjaxEvents>
    </ext:Button>
    Hope this helps.

    Geoffrey McGill
    Founder
  10. #10

    RE: [CLOSED] First steps creating ext:Label derived control

    Hi,

    I am afraid that doesn't help. But I think the fault is in Spring.NET setting these properties at a moment that ViewState isn't fully available yet. I will check their forum and see what I can come up with.

    Thanks,

    Dirk Louwers

Similar Threads

  1. [CLOSED] Creating a control by extending the ext:TextField control
    By Shanth in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: Sep 12, 2011, 2:58 PM
  2. IE9 - are there steps to improve compatibility ?
    By PeterParsonage in forum 1.x Help
    Replies: 4
    Last Post: Mar 25, 2011, 10:58 PM
  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] FormPanel - Hide control - label control
    By seanwo in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Aug 11, 2010, 8:57 AM
  5. [CLOSED] Error creating control
    By flaviodamaia in forum 1.x Help
    Replies: 5
    Last Post: Mar 20, 2009, 8:32 AM

Posting Permissions