Need way to RaisePostBack DirectMethod for multiple Controls

  1. #1

    Need way to RaisePostBack DirectMethod for multiple Controls

    The present RaisePostBack model only allows the calling of a single DirectMethod event. I have need to raise multiple DirectMethods in different UserControls. I'd like to be able to do something like, App.direct.multiple( [ Function1, Function2 ]); on the client, and have Function1 DirectMethod defined in one UserControl and Function2 DirectMethod defined in another UserControl. Internally, on the server-side, Function 1 would be invoked, then Function 2.

    Alternatively, it would be also nice to be able to do something like: App.direct.all( Function ); on the client and have all Controls that contain the named Function invoke in their control load order. That is, each UserControl that contains the DirectMethod with the same Function Name would invoke. I especially like this model for the following reason...

    This has to do with my new UserControl refresh model defined here: http://forums.ext.net/showthread.php...-Hidden-Fields

    The goal is to have each of the UserControl be able to handle their own container refreshes without having to do casting after FindControl to each UserControl's type, just to call it's public Method. For instance, right now my UserControl1 has to know about UserControl2 just to be able to refresh 2 separate containers in each one after a single DirectMethod call. If they instead both had a public DirectMethod with the same public function name (or attributes that define their multiple call relationship), they could manage themselves.

    At present, this is more of a feature request, but for now I'm happy to have you offer a solution in between.

    Ext.Net seems not to warn if I attempt to create the same named public DirectMethod in 2 different UserControls. However, only one gets invoked. If there is an easy way to overcome this limitation, let me know.
  2. #2
    How about configuring [DirectMethods] in each UserControl, then calling multiple DirectMethods from the client shouldn't be a problem?
    Geoffrey McGill
    Founder & CEO
  3. #3
    Quote Originally Posted by geoffrey.mcgill View Post
    How about configuring [DirectMethods] in each UserControl, then calling multiple DirectMethods from the client shouldn't be a problem?
    I think you're posing multiple round-trips which is far from ideal. I'm considering a generic server-side event subscription model in the meantime unless you have a better idea.
  4. #4
    Quote Originally Posted by michaeld View Post
    At present, this is more of a feature request, but for now I'm happy to have you offer a solution in between.
    Yes, we have no such the functionality built-in and you are the first one who has requested it:) I think it is very unlike we will implement it ever.

    The best we can suggest is to call some DirectMethod, say DirectMethodCombined, which calls on server side all the logic that you need to be called.

    Quote Originally Posted by michaeld View Post
    Ext.Net seems not to warn if I attempt to create the same named public DirectMethod in 2 different UserControls. However, only one gets invoked. If there is an easy way to overcome this limitation, let me know.
    It appears to be working here:
    http://examples2.ext.net/#/Events/Di.../UserControls/

    Probably, in your scenario the DirectMethods are rendered with the same proxy name, and a DirectMethod from the second user control overrides the first one.

    Do you use
    [DirectMethod(IDMode=...)]
    or
    [DirectMethodProxyID(IDMode = ...)]
    anywhere?

    If you can provide a sample to reproduce, we can investigate.
  5. #5
    Quote Originally Posted by Daniil View Post
    Yes, we have no such the functionality built-in and you are the first one who has requested it:) I think it is very unlike we will implement it ever.
    I think you'll find a general use-case when you guys get to implementing: https://github.com/extnet/Ext.NET/issues/410
    But as you guys aren't considering the hows as much as the whys yet, I didn't imagine you'd be fast to respond to this request; though, honestly, it seems pretty easy to implement but would require a client and server side implementation that allows the RaisePostBack eventarguments that are passed to support a new type that accepts a list instead of just the single 3-part split arguments.

    Quote Originally Posted by Daniil View Post
    The best we can suggest is to call some DirectMethod, say DirectMethodCombined, which calls on server side all the logic that you need to be called.
    I don't entirely understand what you're posing, but I have already begun to create code to allow general wiring of events to subscribed controls based on type and name.

    So yeah, the DirectMethod can call GlobalNamedEvents.Trigger("RefreshSomePanel") which will invoke each subscribing control EventHandler to that eventname that was registered/wired-up in the Page_Init for that UserControl.

    Quote Originally Posted by Daniil View Post
    Probably, in your scenario the DirectMethods are rendered with the same proxy name, and a DirectMethod from the second user control overrides the first one.
    I used the following DirectMethod attribute (which if I understand correctly makes it public).
        [DirectMethod( IDMode = DirectMethodProxyIDMode.None, ShowMask = true )]
    And yeah, in that case there is no warning or exception. In your example, you aren't setting them to public so the named control will be part of the eventargument and will not override the previous instance. If not that, then it may be because I'm not attaching _dc. I have ResourceManager.CleanResourceUrl=true
    Last edited by michaeld; Jan 08, 2014 at 1:20 PM.
  6. #6
    I will put it into Agenda of our next team meeting.

    Quote Originally Posted by michaeld View Post
    I used the following DirectMethod attribute (which if I understand correctly makes it public).
        [DirectMethod( IDMode = DirectMethodProxyIDMode.None, ShowMask = true )]
    And yeah, in that case there is no warning or exception. In your example, you aren't setting them to public so the named control will be part of the eventargument and will not override the previous instance. If not that, then it may be because I'm not attaching _dc. I have ResourceManager.CleanResourceUrl=true
    Please start a new thread for that.
  7. #7

Similar Threads

  1. [CLOSED] Disable some Controls before DirectMethod
    By pk.net in forum 1.x Premium Help
    Replies: 7
    Last Post: Aug 21, 2012, 10:01 AM
  2. Replies: 2
    Last Post: Jun 22, 2012, 4:17 PM
  3. Prevent multiple calls to DirectMethod
    By glenh in forum 1.x Help
    Replies: 0
    Last Post: May 03, 2012, 1:00 AM
  4. Replies: 6
    Last Post: Apr 05, 2012, 5:23 PM
  5. Multiple ext controls in single anchor (or workaround)
    By dlouwers in forum 1.x Premium Help
    Replies: 4
    Last Post: Dec 04, 2008, 1:53 PM

Posting Permissions