【.Net码农】html+ashx 表单提交示例
来源:互联网 发布:淘宝店怎样增加流量 编辑:程序博客网 时间:2024/06/06 02:30
html+ashx 表单提交示例
感谢 3lian8 的投递 时间:2014-03-24 来源:三联教程
这篇文章主要介绍了html+ashx 表单提交的具体实现,需要的朋友可以参考下
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;
}
}
}
}
0 0
- 【.Net码农】html+ashx 表单提交示例
- html+ashx 表单提交
- 【.Net码农】 jquery访问ashx文件示例
- [.Net码农][MVC]使用Html.BeginForm来提交表单
- Asp.net提交HTML控件表单
- ExtJS 表单提交示例
- Ext 表单提交示例
- html:表单和表单提交
- 使用Asp.net 接收html提交的表单
- asp.net 接收html表单提交如何接收
- 使用Asp.net 接收html提交的表单
- HTML表单提交规则
- HTML 提交表单 效验
- html表单提交事件
- html表单提交
- html - form提交表单
- HTML表单的提交
- HTML表单提交
- java虚拟机内存溢出,eclipse配置
- 【.Net码农】Jquery+ashx实现Ajax
- C++虚基类的作用
- Tomcat端口占用
- 基于Mac的网站临时域名发布小结
- 【.Net码农】html+ashx 表单提交示例
- openfire+smack收发消息
- 元组和数组
- KMP算法实现
- JS获取新浪实时股票行情数据
- 【使用JSOUP实现网络爬虫】修改数据-设置一个元素的HTML内容
- android Jvm 笔记。内存溢出。内存区域划分。垃圾回收气
- Mac配置全局 Composer
- leetCode #55 Jump Game 贪心