I caught up with a project over the past few days. I used Ajax and was ready to study it. But I encountered a strange problem when I first learned it,
I have searched the internet for a long time and no one has mentioned it. Are you doing well in this step? I use visualstudio2003, which is described as follows:
ASP. NET Ajax is mainly divided into five steps (a rough description ):
1 add Ajax reference
2 add in webconfig. xml
<Httphandlers>
<! -- Register the Ajax Handler -->
<Add verb = "post, get" Path = "ajax/*. ashx"
Type = "Ajax. pagehandlerfactory, Ajax"/>
</Httphandlers>
3. Add Ajax. Utility. registertypeforajax (typeof (webform1) to the page_onload () event ));
4. Mark the server code [Ajax. ajaxmethod ()]
5. Call the server in Javascript
The problem lies in the fifth step:
According to the Ajax quickguide, use webform1.getvalue () in JavaScript to call the server method (webform1 is the class I registered, and getvalue () is the server method I registered to call in Javascript ), the execution of IE prompts that "'webform1 'is not registered". It's a fucking thing. It's estimated that no one in the world will encounter this problem. After three days of reinstalling the system, I got nothing and was depressed.
Finally, we copied the JavaScript code in ASP. NET Condiments: Ajax, and solved the problem!
Copy JavaScript code segment (of course, some changes have been made in your program ):
<script language="javascript">WebForm1.GetValue(GetValue_CallBack);function GetValue_CallBack(response){alert(response.value);}</script>
Conclusion: The problem still lies in itself: the calling method in JavaScript code is asymmetrical with the method name defined by the server due to the rush to get the project,
Therefore, JavaScript does not recognize the variable webform1, prompting that 'webform1 'is not registered. In fact, you only need to check the code carefully.
I can find that, fortunately, I have a good determination, and I am dead with him. The problem is solved !!!