足球游戏_中国足彩网¥体育资讯$

html+ashx 表单提交示例
来源:易贤网 阅读:1634 次 日期:2014-08-28 14:28:06
温馨提示:易贤网小编为您整理了“html+ashx 表单提交示例”,方便广大网友查阅!

这篇文章主要介绍了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=gbk"/>

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

}

}

}

}

中国足彩网信息请查看IT技术专栏

中国足彩网信息请查看网络编程
易贤网手机网站地址:html+ashx 表单提交示例
由于各方面情况的不断调整与变化,易贤网提供的所有考试信息和咨询回复仅供参考,敬请考生以权威部门公布的正式信息和咨询为准!
关于我们 | 联系我们 | 人才招聘 | 网站声明 | 网站帮助 | 非正式的简要咨询 | 简要咨询须知 | 加入群交流 | 手机站点 | 投诉建议
工业和信息化部备案号:滇ICP备2023014141号-1 足球游戏_中国足彩网¥体育资讯$ 滇公网安备53010202001879号 人力资源服务许可证:(云)人服证字(2023)第0102001523号
云南网警备案专用图标
联系电话:0871-65317125(9:00—18:00) 获取招聘考试信息及咨询关注公众号:hfpxwx
咨询QQ:526150442(9:00—18:00)版权所有:易贤网
云南网警报警专用图标