tags:

views:

561

answers:

1

Hi,

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

I use ClientScript.RegisterClientScriptInclude in order to include my javascript files. In the JS files I use Type.registerNamespace but when the page loads I get a JS error: "Type is not defined".

What am I doing wrong?

+1  A: 

I found the answer!

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

For example, if you have a javascript file named "JScript1.js", then you can add it to the ScriptManager like this (markup):

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

Or like this (code):

ScriptManager1.Scripts.Add(new ScriptReference("~/JScript1.js"));
Shay Friedman

related questions