Html + ashx form submission

Source: Internet
Author: User

1. sumbit form submission

WebForm1.aspx source code:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="NETFormDemo.ashx.WebForm1" %>
         <script  type="text/javascript">    </script>    

SubmitForm. ashx source code:

Using System; using System. Collections. Generic; using System. Linq; using System. Web; namespace NETFormDemo. ashx {////// Summary of submitForm ///Public class submitForm: IHttpHandler {public void ProcessRequest (HttpContext context) {context. response. contentType = "text/plain"; context. response. write ("Hello World");} public bool IsReusable {get {return false ;}}}}

2. ajax submission



HtmlPage1.html source code:

         <script src="test1.js" type="text/javascript"></script>    <script src="jquery-1.4.min.js" type="text/javascript"></script>        <script type="text/javascript">            function add(url) {                var A = $("#a1").val();                var B = $("#b1").val();                $.ajax({                    url: "ashx/add.ashx?i=" + A + "&j=" + B,                    data: {                        num1: A,                        num2: B                    },                    dataType: "html",                    success: function (result) {                    }                });            }        </script>               
Add. ashx source code:

Using System; using System. Collections. Generic; using System. Linq; using System. Web; namespace NETFormDemo. ashx {////// Login summary ///Public class Login: IHttpHandler {public void ProcessRequest (HttpContext context) {context. response. contentType = "text/plain"; int first = Convert. toInt32 (context. request. params ["I"]); int sec = Convert. toInt32 (context. request. params ["j"]); int res = first + sec; context. response. write (res); context. response. write ("fdd ff");} public bool IsReusable {get {return false ;}}}}


Related Article

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.