1,sumbit form Submission
WebForm1.aspx Source:
Copy Code code as follows:
<%@ Page language= "C #" autoeventwireup= "true" codebehind= "WebForm1.aspx.cs" inherits= "NETFormDemo.ashx.WebForm1" %>
<! DOCTYPE html>
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title></title>
<script type= "Text/javascript" >
</script>
<body>
<form id= "Form1" action= "Submitform.ashx" >
<div>
<input type= "Submit" value= "submitted"/>
</div>
</form>
</body>
Submitform.ashx Source:
Copy Code code as follows:
Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Web;
Namespace Netformdemo.ashx
{
<summary>
Summary description of SubmitForm
</summary>
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 Submit
Htmlpage1.html Source:
Copy Code code as follows:
<! DOCTYPE html>
<title></title>
<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>
<body>
<form id= "Form1" runat= "Server" >
<input type= "Text" id= "A1"/>
<input type= "text" id= "B1"/>
<input type= "button" onclick= "Add ()"/>
<label id= "LB" ></label>
</form>
</body>
Add.ashx Source:
Copy Code code as follows:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
Namespace Netformdemo.ashx
{
///<summary>
///Login Summary description
///</summary>
public class Login:ihttphandler
{
public void ProcessRequest (HttpContext context)
{
Co ntext. Response.ContentType = "Text/plain";
Int-A-convert.toint32 (context. request.params["I"]);
Int sec = Convert.ToInt32 (context. Request.params["J"]);
Int res = the i + sec;
Context. Response.Write (RES);
Context. Response.Write ("FDD ff");
}
public bool isreusable
{
Get
{
return false;
}
}
}
}