html+ashx 表单提交示例
程序员文章站
2024-02-23 16:27:04
1,sumbit表单提交 webform1.aspx源码: 复制代码 代码如下: <%@ page language="c#" autoeventwireup="tr...
1,sumbit表单提交
webform1.aspx源码:
<%@ page language="c#" autoeventwireup="true" codebehind="webform1.aspx.cs" inherits="netformdemo.ashx.webform1" %>
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head >
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title></title>
<script type="text/javascript">
</script>
</head>
<body>
<form id="form1" action="submitform.ashx" >
<div>
<input type="submit" value="提交" />
</div>
</form>
</body>
</html>
submitform.ashx源码:
using system;
using system.collections.generic;
using system.linq;
using system.web;
namespace netformdemo.ashx
{
/// <summary>
/// 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提交
htmlpage1.html 源码:
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<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>
</head>
<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>
</html>
add.ashx源码:
using system;
using system.collections.generic;
using system.linq;
using system.web;
namespace netformdemo.ashx
{
/// <summary>
/// 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;
}
}
}
}
webform1.aspx源码:
复制代码 代码如下:
<%@ page language="c#" autoeventwireup="true" codebehind="webform1.aspx.cs" inherits="netformdemo.ashx.webform1" %>
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head >
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title></title>
<script type="text/javascript">
</script>
</head>
<body>
<form id="form1" action="submitform.ashx" >
<div>
<input type="submit" value="提交" />
</div>
</form>
</body>
</html>
submitform.ashx源码:
复制代码 代码如下:
using system;
using system.collections.generic;
using system.linq;
using system.web;
namespace netformdemo.ashx
{
/// <summary>
/// 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提交
htmlpage1.html 源码:
复制代码 代码如下:
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<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>
</head>
<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>
</html>
add.ashx源码:
复制代码 代码如下:
using system;
using system.collections.generic;
using system.linq;
using system.web;
namespace netformdemo.ashx
{
/// <summary>
/// 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;
}
}
}
}
上一篇: 详解sql中的参照完整性(一对一,一对多,多对多)
下一篇: mysql多表联合查询操作实例分析
推荐阅读
-
html+ashx 表单提交示例
-
jquery提交表单mvc3后台处理示例
-
Spring Boot使用AOP防止重复提交的方法示例
-
Asp.Net模拟表单提交数据和上传文件的实现代码
-
Servlet的5种方式实现表单提交(注册小功能),后台获取表单数据实例
-
php中限制ip段访问、禁止ip提交表单的代码分享,ip表单
-
如何交表单的textarea提交的文本的回车,转化为
-
一个表单两个提交按钮交付不同页面
-
Yii2.0 模态弹出框+ajax提交表单,yii2.0ajax
-
在Tapestry中使用redirect-after-post模式控制表单提交 博客分类: Tapestry4 Tapestry设计模式ApacheOOAjax