[OPEN] [#410] UserControl Auto-Loader & Manager

  1. #1

    [OPEN] [#410] UserControl Auto-Loader & Manager

    Hi guys, I'm started writing a generalized UserControlManager control that can be added to a page or control that creates a bunch of hidden fields that indicate whether and which UserControls to reload on PostBack/DirectEvents/DirectMethods to reattach each UserControl's DirectEvents.

    For instance, you manually manage this in your example here, https://examples2.ext.net/#/XRender/...UpdateContent/. You also do this in other samples which indicates to me that there is a real need for this in ext.net and that I shouldn't have to roll-my-own.

    If you continue this model for dozens of user controls, you'd have to write the client-side logic to manage each and every control. Ideally, my feature request is to build this into ext.net. It would be easier to simply call a method in ResourceManager like RegisterUserControl() or similar, and have the the registered UserControls automatically load each time in post-back to the appropriate parent. We'd also need a method to unregister controls or clear them.

    Scoping to the page would be easy if ResourceManager automatically generated a unique key in a hidden field on every get request upon the first call to RegisterUserControl(). A NewGuid should do the trick. Post would use this key for referencing.

    Additionally there might be security concerns related to what could/should be stored in the hidden field as the user control's name or even a mapped reference could allow a savvy hacker to cross-site replace the UserControl with another if its just pure-text. However, that is easily addressed by encrypting the reference ids based on the unique key scoped to the page, and ensuring that another half of the key is stored in web.config on the server which the hacker could never gain access to.

    An example of the pure text (pre-encryption) for the UserControl hidden field might contain "~/UserControl1.ascx;ParentCtrl;uc1;Static;None" where the split(';') references the control name, the parent control id to add to, the id of the UserControl, the idmode of the rendered control, and whether to rerender/updatecontent of the loaded control. There might be more but I'm just thinking out-loud here. Registering should be allowed manually or automatically by setting a bool attribute AutoRegisterUserControl to UserControlRendererConfig and UserControlLoader and other related ext.net control loader api.

    This just seems very natural to me that ext.net should have a way to manage the developer's loaded UserControl resources without being forced to constantly recreate their own logic to do the same.
    Last edited by Daniil; Dec 27, 2013 at 5:11 AM. Reason: [OPEN] [#410]
  2. #2
    I have implemented a non-ResourceManager implementation here.

    http://forums.ext.net/showthread.php?27618-Add-UserControls-in-DirectEvents-Methods-and-have-them-automatically-Reload-on-Post-back-through-messanging-in-Hidden-Fields&p=122873#post122873



    Ideally, I'd like to see this added to Ext.Net as part of ResourceManager or Ext.Net in some appropriate way. I've done some of the leg-work and testing for proof of concept in that thread.
    Last edited by michaeld; Dec 18, 2013 at 10:59 PM.
  3. #3
    New more reliable version posted at link above with sample test app.
  4. #4
    Thank you for the request. Created an Issue:
    https://github.com/extnet/Ext.NET/issues/410
  5. #5
    Quote Originally Posted by Daniil View Post
    Thank you for the request. Created an Issue:
    https://github.com/extnet/Ext.NET/issues/410
    Nice. Feel free to use any of the code I posted and tested.

Similar Threads

  1. Replies: 5
    Last Post: Jun 12, 2013, 2:49 AM
  2. Create client-side window with auto loader
    By pcoimbrao in forum 2.x Help
    Replies: 3
    Last Post: Jan 31, 2013, 4:55 PM
  3. [CLOSED] Register UserControl with Loader
    By softmachine2011 in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Jul 16, 2012, 1:42 PM
  4. Script Manager and Resource Manager Conflict
    By EugeneNiemand in forum 1.x Help
    Replies: 6
    Last Post: Jun 20, 2011, 7:34 AM
  5. Replies: 1
    Last Post: Jun 10, 2010, 11:28 AM

Posting Permissions