AJax错误"WebForm1"没有定义的javascript错误的解决方法

笔者在研究QuickGuide.txt的文章同时,按照顺序一步步的做法,结果运行时,发现老是出现这样的错误 ,"WebForm1"没有定义的javascript错误,换了以该项目为根目录,错误照旧

使用google在网络里查询,结果发现很多朋友也发生同样的错误.

于是产生欢迎该dll是否download的不正确. 但是照着文档资料查询了一下

private void Page_Load(object sender, System.EventArgs e)

{

// 在此处放置用户代码以初始化页面

Ajax.Utility.RegisterTypeForAjax(typeof(WebForm1));

}

这里设置后,web里面会产生代码

<script type="text/javascript" src="/ajax/common.ashx"></script>

<script type="text/javascript" src="/ajax/AJAX_Test.WebForm1,AJAX_Test.ashx"></script>

这证明dll能够发生作用,也就是说该dll能正常运行.到底错误怎么产生的呢??

根据

The call to RegisterTypeForAjax emits the following JavaScript on the page (alternatively, you could manually place the following two lines on the page):

<script language="javascript" src="ajax/common.ashx"></script>

<script language="javascript"

src="ajax/NAMESPACE.PAGECLASS,ASSEMBLYNAME.ashx"></script>

Where the bolded parts have the following meaning:

NAMESPACE.PAGECLASS

The namespace and class of the current page

(this will typically be the value of the Inherits attribute in the @Page directive)

ASSEMBLYNAME

The name of the assembly the current page is part of

(this will typically be the name of your project)

发现该产生的code 必须是ajax/为根的,所以按照上面描述,人工加上一段code在aspx文件里

<script type="text/javascript" src="ajax/common.ashx"></script>

<script type="text/javascript" src="ajax/AJAX_Test.WebForm1,AJAX_Test.ashx"></script>

private void Page_Load(object sender, System.EventArgs e)

{

// 在此处放置用户代码以初始化页面

// Ajax.Utility.RegisterTypeForAjax(typeof(WebForm1)); 注销这段代码

}

结果运行正确.

得到的结论是,可能是该ajax的一个小Bug,产生的js代码不对.但是可以根据上述的规则人为添加js代码