Jquery asynchronous post

Source: Internet
Author: User

Jquery asynchronous post

1. For An aspx webpage, you only need to place the html button tag of the form tag as input type = "submit", whether or not to add runat = "server" to the form, clickWill be the same as the Server ControlProcess the. cs file after sending the request.

For example

 <form id="form1">    <div>      <input class="subBtn" type="submit" />    </div></form>

 

2. Use

<form id="form1">   <div>     <input class="subBtn" type="button" />   </div></form>

This method can be obtained by jquery on the page and asynchronously transmitted to the specified background using the post method.

 

3.The <asp: label> label in Asp.net is displayed as a <span> label on the browser end, for example, assigning or obtaining data from the returned data, $ ("") is required (""). text () method;

In asp.net, the <asp: TextBox> tag is displayed as a <input> tag on the browser end, for example, assigning or obtaining data from the returned data, $ ("") is required (""). val () method;

The final expression can be obtained by viewing the source code on the generate page.

 

4. debugging: My debugging method is visual studio plus. cs code breakpoint + firefox firebug breakpoint method, the two can work together, for example, click the button tag of the input type, call the background to add the breakpoint's ashx file, skip the breakpoint, you can go to the breakpoint in firebug for debugging.

(Microsoft and other browsers have been used, but they do not feel as useful as firefox firebug. At least they are better at viewing the layout and related css)

 

5. If session is used in the ashx file, special processing is required.

Here I reference an article:

 

On the general transaction processing page, you can easily obtain the Request and Response objects and perform the following operations:

HttpRequest Request = context. Request;

HttpResponse Response = context. Response;

However, it is not that easy to obtain the Session value. For example, you need to obtain the Logon account Session ["userAccount"] stored in the Session in ashx.

If you only use context. Session ["userAccount"], an exception will be reported "the object has not been referenced to the instance of the object ".

Therefore, if you want to obtain the value in the Session, you need

1. Introduce the namespace:

Using System. Web. SessionState;

2. Implement the IRequiresSessionState interface as follows:

/// <Summary>
/// $ Codebehindclassname $ abstract description
/// </Summary>
[WebService (Namespace = "http://tempuri.org/")]
[WebServiceBinding (ConformsTo = WsiProfiles. BasicProfile1_1)]
Public class AddUserInfo: IHttpHandler, IRequiresSessionState // This is the implementation of the display. No implementation method is required.
{

Public void ProcessRequest (HttpContext context)
{

//...

// You can perform the following operations:

If (context. Session ["userAccount"]! = Null)

{

String account = context. Session ["userAccount"]. ToString ();

}

//... Continue the following code

}

}

 

 

 



 

 

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.