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