[CLOSED] DisableControl="true" on CodeBehind

  1. #1

    [CLOSED] DisableControl="true" on CodeBehind

    Hi,

    I'm trying to copy the behaviour of DisableControl in Codebehind.

    for example, in my .aspx file I got this button and it works fine:

     <ext:ImageButton
                            
                            id="botonmas"
                            MinWidth="10"
                            Width="45"
                            Height="45"
                            class="tip-target"
                            ToggleGroup="GroupRss"
                            MarginSpec="0 0 0 10"
                            runat="server"
                            ImageUrl="/img/more.png"
                            OverImageUrl="/img/more(1).png">
                            <DirectEvents>
                                <Click DisableControl="true" OnEvent="CargarMas"></Click>
                            </DirectEvents>
                            
                        </ext:ImageButton>
    I want make the same thing in codebehing, but I dont get to know how to do it.

    Here is the button in codebehind where I want to do it.
    Ext.Net.ImageButton btnañadir = new Ext.Net.ImageButton();
                    btnañadir.ID = "btnañadir" + nitem.ToString();
                    btnañadir.MinWidth = 10;
                    btnañadir.Width = 79;
                    btnañadir.Height = 32;
                    btnañadir.ImageUrl = "/img/button_anadir.png";
                    btnañadir.OverImageUrl = "/img/button_anadir(1).png";
                    panelbtnañadir.Add(btnañadir);
    
                    btnañadir.Listeners.Click.Handler = "App.direct.VistaDetallada(e.clientY,'" + item.Modelo.TrimEnd() + "','" + btnañadir.ID + "')";
    thank You
    Last edited by fabricio.murta; Dec 28, 2018 at 11:40 PM. Reason: no feedback from the user in 7+ days
  2. #2
    Hello, @PascuV!

    You just set the button direct event's DisableControl as true just like you do in markup.

    For instance:

    btnañadir.DirectEvents.Click.DisableControl = true;
    If your code is still not working, that might be another reason, a topic rather explored already here in forums, so I will just link you some discussions related to it. Let us know if you still don't get it working the way you need.

    - DirectEvent: Click Event in code behind troubles
    - Adding A Menu Item with a DirectEvent from a Page_Load

    Basically, if you fall in this issue, is because you are not persisting the control between requests. When you draw a component from markup, it is always available to code behind (its initial state) no matter what. When you dynamically set it from code behind, it will exist to the server only during the request.

    What I missed in the threads linked above is the actual code to add the component every request. It should be added every time a request happens, but adding it at the time the specific direct event code runs does not suffice. One "sure shot" location would be the Page_Load event, as long as you ensure it runs regardless of isPostBack and Ext.Net.IsAjaxRequest status:

    this.Page.Controls.Add(btnañadir);
    Hope this helps!
    Fabrício Murta
    Developer & Support Expert
  3. #3
    Hello @PascuV!

    It's been a while since we posted a response to this thread, yet no feedback from you as of now. Do you still need help with this, or did our response help you out solve the issue?

    We may mark this thread as closed if you don't post a follow-up in 7+ days from now. We don't lock up threads, so you'll still be able to post back here even after we mark it as closed.
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. Replies: 8
    Last Post: Aug 11, 2015, 1:52 PM
  2. Replies: 1
    Last Post: Oct 05, 2012, 11:56 AM
  3. [CLOSED] Hidden="true" behaves as Visible="false"
    By marco.morreale in forum 2.x Legacy Premium Help
    Replies: 5
    Last Post: May 28, 2012, 3:17 PM
  4. Replies: 5
    Last Post: May 02, 2012, 5:37 PM
  5. [CLOSED] DropDownField with Grow="true" and GrowMax="xxx"
    By deejayns in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Jan 12, 2012, 12:00 PM

Posting Permissions