[CLOSED] Looking for way to use DirectMethods inside UserControl

  1. #1

    [CLOSED] Looking for way to use DirectMethods inside UserControl

    Hi,

    I have found how to call a DirectMethod inside UserControl but only if this DirectMethod is on page contains this control.

    so question is How to call DirectMethod which is implemented inside UserControl from for example ext:Button (button is also inside UserControl)?

    Hope I've made it clear enough if not please ask:)

    Edit

    What is requirement to pass parameters into DirectMethod?
    I've tryed to pass
    this.activeItem
    inside tabPanel listeners tabchange event but got error:
    call of this DirectMethod:
    <TabChange Handler="if(tab.items.getCount()>0) { return false; } else { #{DirectMethods}.AddTab(this.activeItem); }"></TabChange>
    System.ArgumentException: DirectMethod: 'AddTab', The parameter 'activeItem' is undefined at Ext.Net.DirectMethod.Invoke(Object target, HttpContext context, ParameterCollection args) at Ext.Net.DirectMethod.Invoke(Object target, ParameterCollection args) at Ext.Net.ResourceManager.RaisePostBackEvent(String eventArgument)
    my code behind looks like:
            [DirectMethod(Timeout = 30000)]
            public void AddTab(string activeItem)
            {
                Ext.Net.Panel panel = tPanel.Items.FirstOrDefault(x => x.ClientID == activeItem) as Ext.Net.Panel;
            }
            [DirectMethod(Timeout = 30000)]
            public void AddTab(int activeItem)
            {
                Ext.Net.Panel panel = tPanel.Items[activeItem] as Ext.Net.Panel;
            }
    I've figured it out:
    solution:
    <TabChange Handler="if(tab.items.getCount()>0) { return false; } else { #{DirectMethods}.AddTab(tab.id); }"></TabChange>
    This thread can be closed:)

    Thanks,
    ViDom
    Last edited by Daniil; Dec 19, 2012 at 11:11 AM. Reason: [CLOSED]
  2. #2
    Hi @ViDom,

    Here is an example how to call DirectMethods from UserControls.
    https://examples1.ext.net/#/Events/D.../UserControls/

    To get an index of just an activated tab, please use:
    this.items.indexOf(tab)
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi @ViDom,

    Here is an example how to call DirectMethods from UserControls.
    https://examples1.ext.net/#/Events/D.../UserControls/

    To get an index of just an activated tab, please use:
    this.items.indexOf(tab)
    Thanks @Daniil I've found this example a minute ago and make my problem work:) I've edited previous post and share solution which fit my needs as well as yours:)

Similar Threads

  1. Replies: 4
    Last Post: Dec 19, 2012, 9:58 AM
  2. Replies: 1
    Last Post: Apr 03, 2012, 9:36 AM
  3. XRender call DirectMethods from UserControl
    By vucuongkg in forum 2.x Help
    Replies: 1
    Last Post: Mar 19, 2012, 10:58 AM
  4. Replies: 8
    Last Post: Feb 15, 2012, 9:04 AM
  5. Help with UserControl inside window
    By dbassett74 in forum 1.x Help
    Replies: 0
    Last Post: May 26, 2009, 4:25 PM

Tags for this Thread

Posting Permissions