The Webform.aspx page accesses the methods in the WebForm.aspx.cs class through AJAX to get the data
WebForm1.aspx page (native Ajax request, notation one)
<%@ page language= "C #" autoeventwireup= "true" codebehind= "WebForm1.aspx.cs" inherits= "Ispostback.webform1"%> <! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
WebForm1.aspx page (native Ajax request, notation Two, normally we use this)
WebForm1.aspx.csIf you are using Response.End () inside the Try...catch, you will be caught with an exception: Thread aborted "Workaround: Click
Using system;using system.collections.generic;using system.linq;using system.web;using System.Web.UI;using System.web.ui.webcontrols;using system.data.sqlclient;using system.data;namespace IsPostBack{public partial class WebForm1:System.Web.UI.Page {protected void Page_Load (object sender, EventArgs e) {string id = request["id"]; If the data is not submitted through an AJAX request, the ID is not taken, so the ID at this time is null. However, if the data is submitted through an AJAX request, because there is a commit ID in the commit data, the ID can be taken, and the ID will have a value at that time. if (!string. IsNullOrEmpty (ID))//If the data is not submitted through an AJAX request, it will not enter the curly braces to invoke the Getuserdata (string id) method {getuserdata (ID); If the data is submitted through an AJAX request, it enters the curly braces to invoke the Getuserdata (string id) method}} void Getuserdata (string id) {DataTable dt= sqlhelper.executedatatable ("select * from T_user where [email protected]", New SQL Parameter ("id", id)); String Data= Datatableconvertjson.datatabletojson ("Json", DT); Response.Write (data); RespOnse. End (); Send all current buffered output to the client, stop the execution of the page, and if this is not the case, the program will be executed backwards, in addition to outputting data to the client, the HTML code inside the WebForm1.aspx will be output to the page. } }}
The Webform.aspx page accesses the methods in the WebForm.aspx.cs class through AJAX to get the data