Question regarding ClientScriptResource and ASCX controls
See original GitHub issueHi,
I am in the process of trying to update our code base to .Net 4.6.1 and also update the Toolkit from 4.6 to 16.1 (I know, this is far from ideal). So far I have been able to get most controls to build and function correctly with the exception of around 6 ascx controls. The team that build these controls back in 2009-2010 used the ClientScriptResource tag along with the ScriptUserControl in the Toolkit to embed javascript files that handled all of the control’s AJAX. I removed all references to the ScriptUserControl and the controls build but the embedded javascript files are no longer being loaded into the browser. All of the controls were setup as follows:
<Assembly: WebResource("ProjectName.OrderQuantityBehavior.js", "text/javascript")> <ClientScriptResource("ProjectName.OrderQuantityBehavior", "ProjectName.OrderQuantityBehavior")> _ Partial Public Class OrderDatesAndQuantityControl
The javascript files are located in a subfolder where all of the controls are located, specifically Controls/App_LocalResources/Scripts. I have tried different paths, different namespaces, and moving files around and I cannot find anything that will load the JS correctly. The frustrating part is that I can’t even get an error to throw. No console errors, no Visual Studio exceptions, nothing. Is this a simple issues of the paths needed changed or is there something else I need to add to get these javascript files back into the browser?
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (4 by maintainers)
This control is pretty complex. It has several date fields that all interact with one another and also complies an order quantity amount based on the days selected. Between this and the 4 or 5 other controls built this way, I don’t know if we would currently have the time to change the architecture. I will have to try the other method you described yesterday using the RegisterControlScriptResource and see if that might help. Thank you for your help!
Thank you for the image. As the error message states, you cannot use an arbitrary class with the @Control directive, because it implies that the class is derived from the
System.Web.UI.UserControl
class.Converting
UserControl
toScriptControlBase
requires changing the architecture of the application. It’s currently difficult to guess how complex your control is, so it would be nice if you provide a code sample that illustrates your controls’ structure.