[求助]asp.net编程问题好多好多哦!
WebForm1.aspx.cs代码如下:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace testAjax
{
/// <summary>
/// WebForm1 的摘要说明。
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{// 在此处放置用户代码以初始化页面
// 注册Ajax类型;
Ajax.Utility.RegisterTypeForAjax(typeof (WebForm1));
}
//添加服务器端方法,并加上Ajax.AjaxMethod()的属性标签;
//实现一个简单的加法运算;
[Ajax.AjaxMethod()]
public int ServerSideAdd(int firstNumber,int secondNumber)
{
return firstNumber + secondNumber;
}
WebForm1.aspx.cs代码如下:
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="testAjax.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<script>
function ClientAdd()
{
int first=document.all("first");
int second=document.all("second");
int result=document.all("result");
//在客户端通过JavaSript脚本调用服务端的方法;
result.value=WebForm1.ServerSideAdd(frist.value,second.value).value;
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<INPUT id="first" type="text" size="5"> + <INPUT id="second" type="text" size="5">
=<INPUT id="result" type="text" size="5">
<INPUT id="calc" type="button" value="计算" onclick="JavaScript:ClientAdd()">
</form>
</body>
</HTML>
运行后提示缺少;
缺少对象;
按计算按钮不响应!
这是怎么回事呀?
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace testAjax
{
/// <summary>
/// WebForm1 的摘要说明。
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{// 在此处放置用户代码以初始化页面
// 注册Ajax类型;
Ajax.Utility.RegisterTypeForAjax(typeof (WebForm1));
}
//添加服务器端方法,并加上Ajax.AjaxMethod()的属性标签;
//实现一个简单的加法运算;
[Ajax.AjaxMethod()]
public int ServerSideAdd(int firstNumber,int secondNumber)
{
return firstNumber + secondNumber;
}
WebForm1.aspx.cs代码如下:
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="testAjax.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<script>
function ClientAdd()
{
int first=document.all("first");
int second=document.all("second");
int result=document.all("result");
//在客户端通过JavaSript脚本调用服务端的方法;
result.value=WebForm1.ServerSideAdd(frist.value,second.value).value;
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<INPUT id="first" type="text" size="5"> + <INPUT id="second" type="text" size="5">
=<INPUT id="result" type="text" size="5">
<INPUT id="calc" type="button" value="计算" onclick="JavaScript:ClientAdd()">
</form>
</body>
</HTML>
运行后提示缺少;
缺少对象;
按计算按钮不响应!
这是怎么回事呀?