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 ;}}}}