"Type not defined" when using Asp.Net AJAX Type.registerNamespace

I have an ASP.Net 3.5 web application. I have a page with ScriptManager inside.

I am using ClientScript.RegisterClientScriptInclude to include javascript files. In JS files, I use Type.registerNamespace, but when the page loads, I get a JS: "Type not defined" error.

What am I doing wrong?

+3
source share
1 answer

I found the answer!

Instead of including JS files through ClientScript.RegisterClientScriptInclude, they should be added to ScriptManager as ScriptReference elements through markup or code.

, javascript "JScript1.js", ScriptManager, ():

<Scripts>
<asp:ScriptReference Path="~/JScript1.js" />
</Scripts>
</asp:ScriptManager>

():

ScriptManager1.Scripts.Add(new ScriptReference("~/JScript1.js"));
+2

Source: https://habr.com/ru/post/1722687/


All Articles