如题
解决方案 »
- C# 防止 点击TreeView节点时闪动
- 怎样用C#操作Excel表
- 读取txt文件时的问题
- 我在outlook里加了Ribbon,为什么运行的时候没有反应,在word2007里就直接看到效果了
- 如何用sql命令创建一个忽略重复行的唯一的索引
- webBrowser1錯誤屏蔽
- 一道经典Csharp编程题,请教大家,作为掌握数组的入门不错的说...
- 让迅雷开始下载所有未完成任务怎么做,求代码
- C++的类型"unsigned char"转成C#的类型?
- SQLserver 安装的问题!为什么我在win 2000 professional 上装不能装SQL服务器,只能装客户端
- ◆如何生成8位随机码◆
- 窗体上的状态栏控件和工具栏控件(急啊!)
web:
前台:<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Add.aspx.cs" Inherits="Add" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Ajax应用之加法运算</title>
<script type="text/javascript">
var xmlHttp;
function createXMLHttpRequest()
{
if(window.ActiveXObject)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest)
{
xmlHttp=new XMLHttpRequest();
}
}
function addNum()
{
createXMLHttpRequest();
var url="Handler.ashx?Num1="+document.getElementById("num1").value+"&Num2="+document.getElementById("num2").value
xmlHttp.open("GET",url,true);
xmlHttp.onreadystatechange=showResult;
xmlHttp.send(null);
}
function showResult()
{
if(xmlHttp.readyState==4)
{
if(xmlHttp.status==200)
{
document.getElementById("result").value=xmlHttp.responseText;
}
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input id="num1" type="text" onkeyup="addNum()"/>+<input id="num2" type="text" onkeyup="addNum()"/>=
<input id="result" type="text" /></div>
</form>
</body>
</html>
一般处理程序:<%@ WebHandler Language="C#" Class="Handler" %>using System;
using System.Web;public class Handler : IHttpHandler {
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
int result = Convert.ToInt32(context.Request.QueryString["Num1"]) + Convert.ToInt32(context.Request.QueryString["Num2"]);
context.Response.Write(result);
}
public bool IsReusable {
get {
return false;
}
}}
{
var price=document.getElementById("lblPrice");
var num=document.getElementById("txtQuantity");
var L = document.getElementById("lblAmount");
if((num.value=="") || (checkSapce(num.value)))
{
alert("<%= FSSoft.Web.UI.Language.Msg("a00012") %>");
num.focus();
window.event.returnValue=false;
return false;
}
if(isNaN(num.value)==true)
{
alert("<%= FSSoft.Web.UI.Language.Msg("a00013") %>");
num.focus();
window.event.returnValue=false;
return false;
}
//求出实际金额
var ey = parseFloat(price.innerHTML);
var ewai=parseFloat(num.value);
L.innerHTML = (ey * ewai).toFixed(2);
}
function checkSapce (str)
{
//alert(str);
var re = /^\s+$/;
return (re.test(str));
} <FSSoft:CNumTextBox ID="txtQuantity" runat="server" onchange='Setcount()' MaxLength="8" style="width:50px;height:35;" CheckNumType="ZZValidInt1">0</FSSoft:CNumTextBox>