Dec 13, 2013, 12:11 AM
[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.
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]