Author: Cui Chikun (Richard Troy-Rex, RickTroy)
Contact: [email protected] , http://ricktroy.cnblogs.com/
Yesterday I was looking for a simple solution to the use of Ajax in ASP.NET V1.1.4322, but found that the ASP.NET page model is very "weird". Among all the events and internal methods it has, none seems to be able to collect the solution without refreshing the page. Even if the XmlHttpRequest in the page is used to perform HTTP GET, the Page_Load event is not executed (because there is no test result in the Page_Load code in the responseText of XmlHttpRequest ).
Later I hope to use HtmlControl, and then use __doPostBack(EventTarget, EventArgument); to script RaisePostBackEvent but found that once the form is submitted, the page will be refreshed (later I found out that this is common sense of Html forms, I have never learned it before) .But even if you use HtmlControl to perform HTTP GET of XmlHttpRequest, the problem still cannot be solved (the Page_Load event does not respond as above).
PS: For those who want to imitate WebControl for server PostBack, you can write two hidden Inputs on the client, named __EVENTTARGET and __EVENTARGUMENT, and then use the syntax of the script __doPostBack(control, argument); to trigger the PostBack event.
Only after borrowing someone else's Professional ASP.NET did I know that IHttpHandler and IHttpModule can be used in the ASP.NET model to make HTTP requests. Processing, but these two classes require pre-compilation. In this case, even if a response library can be written, its scalability is not optimistic.
Can you please give me some advice, are there any events and methods that can directly respond to and process HTTP requests on the page?
Or who can provide some form submit() method to pass the data format?
Because XmlHttpRequest can be sent at the time of request, if we know the form of submit data, it seems that we can submit the data without refreshing (but I have also considered that this seems to have security risks).
Please give me your advice.