Ajax error WebForm1 A workaround for JavaScript errors that are not defined

Source: Internet
Author: User
Tags add object
ajax|javascript|web| Error | Solve the author in the study of QuickGuide.txt article at the same time, according to sequential Step-by-step approach, the results of the run, found that always appear such errors, "WebForm1" does not define JavaScript errors, Changed to the root of the item, the error is the same
Using Google to search the web, it turns out that many friends have the same mistakes.
It then arises whether the DLL is download incorrect. But I've been searching the documentation

private void Page_Load (object sender, System.EventArgs e)
{
Place user code here to initialize page
Ajax.Utility.RegisterTypeForAjax (typeof (WebForm1));
}

After setting up here, the web will generate code
<script type= "Text/javascript" src= "/ajax/common.ashx" ></script>
<script type= "Text/javascript" src= "/ajax/ajax_test.webform1,ajax_test.ashx" ></script>

This proves that a DLL can work, that is, that the DLL works. How did the mistake come about?

Under

The call to Registertypeforajax emits the following JavaScript in the page (alternatively, you could manually place the FO Llowing 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 would typically be the value of the Inherits in the @Page Directive)

AssemblyName

The name of the Assembly the current page are part of

(This would typically be the name of your project)


Found that the generated code must be ajax/, so as described above, manually add a section of code in the ASPX file
<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)
{
Place user code here to initialize page
Ajax.Utility.RegisterTypeForAjax (typeof (WebForm1)); Log out of this piece of code
}
The results are running correctly.
The conclusion is that it may be a small bug in the Ajax, the resulting JS code is not correct. But you can add JS code to the above rules



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.