Javascript Files can’t be registered when using RegisterClientScriptResource in Custom Controls
I was trying to embed javascript file in a custom web control. I add the following line code in RenderControls method of the control.
Page.ClientScript.RegisterClientScriptResource(typeof(SampleCalendar), "TestWeb.Files.test.js");
When I tested a page containing the control, I realized the script is not registered. After investigation, I have found that I need to add this line of code in PreRender event of the control not in the RenderControls method (which make sense!)
Advertisement


leave a comment