question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question regarding ClientScriptResource and ASCX controls

See original GitHub issue

Hi,

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:closed
  • Created 7 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
cshomo11commented, Sep 7, 2016

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!

0reactions
MikhailTymchukDXcommented, Sep 7, 2016

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 to ScriptControlBase 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

more instance of ascx on same page - Stack Overflow
Now, the problem is that I have an aspx page that needs to implement the ascx twice. One in a principal div and...
Read more >
How to add code-behind to a User Control?
Add the User Control via the templates, do Project -> Add -> New Item -> User Control. This creates the ASCX and the...
Read more >
ASP.Net Interview Questions and Answers - Google Sites
1 :: What is view state and use of it? The current property settings of an ASP.NET page and those of any ASP.NET...
Read more >
Passing data btw two ascx controls... - MSDN - Microsoft
I need to pass data from usercontrol2 to usercontrol1 via property get/set etc., when a I reload page default.aspx or hit a button...
Read more >
ASP.NET Interview Questions on web user controls
ascx ) to your project. 2. Draw the visual interface of the control in the designer. 3. Write code to create the control's...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found