<title>Untitled Page</title>
<script language = "javascript">
function button_OnClick()
{
requestValue = CarService.GetCarValue
(document.getElementById("textbox1").text,document.getElementById("textbox2").text,document.getElementById("textbox3").text,OnComplete,OnTimeOut);
return false;
}
function OnComplete(result)
{
alert("Car is worth:$" + result);
}
function OnTimeOut(result)
{
alert("Timeout:" + result);
}
</script>
</head><body >
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<asp:ServiceReference Path = "~/CarService.asmx" />
</Services>
</asp:ScriptManager>
<label id = "label1" runat = "server">Make:</label>
<asp:TextBox ID = "textbox1" runat = "server"></asp:TextBox>
<br />
<label id = "label2" runat = "server">Model:</label>
<asp:TextBox ID = "textbox2" runat = "server"></asp:TextBox>
<br />
<label id = "label3" runat = "server">Year:</label>
<asp:TextBox ID = "textbox3" runat = "server"></asp:TextBox>
<br />
<input type = "button" id = "button" runat = "server" onclick = "button_OnClick();" value = "Get Value" />
以上为Default.aspx代码
[WebMethod]
[ScriptMethod]
public static int GetCarValue(string strCarMake,string strCarModel,int strCarYear)
{
int nReturn = 0;
if (strCarMake == "Honda")
nReturn = 30000;
else
nReturn = 20000;
if (strCarModel == "Polot")
nReturn += 10000;
int nDepreciation = (System.DateTime.Now.Year - strCarYear) * 2000;
nReturn -= nDepreciation;
return Math.Max(0, nReturn);
}
以上为CarService.cs代码(web service函数)现在报的错是Default.aspx中 requestValue = CarService.GetCarValue这个函数CarService未定义
怎么解决
<script language = "javascript">
function button_OnClick()
{
requestValue = CarService.GetCarValue
(document.getElementById("textbox1").text,document.getElementById("textbox2").text,document.getElementById("textbox3").text,OnComplete,OnTimeOut);
return false;
}
function OnComplete(result)
{
alert("Car is worth:$" + result);
}
function OnTimeOut(result)
{
alert("Timeout:" + result);
}
</script>
</head><body >
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<asp:ServiceReference Path = "~/CarService.asmx" />
</Services>
</asp:ScriptManager>
<label id = "label1" runat = "server">Make:</label>
<asp:TextBox ID = "textbox1" runat = "server"></asp:TextBox>
<br />
<label id = "label2" runat = "server">Model:</label>
<asp:TextBox ID = "textbox2" runat = "server"></asp:TextBox>
<br />
<label id = "label3" runat = "server">Year:</label>
<asp:TextBox ID = "textbox3" runat = "server"></asp:TextBox>
<br />
<input type = "button" id = "button" runat = "server" onclick = "button_OnClick();" value = "Get Value" />
以上为Default.aspx代码
[WebMethod]
[ScriptMethod]
public static int GetCarValue(string strCarMake,string strCarModel,int strCarYear)
{
int nReturn = 0;
if (strCarMake == "Honda")
nReturn = 30000;
else
nReturn = 20000;
if (strCarModel == "Polot")
nReturn += 10000;
int nDepreciation = (System.DateTime.Now.Year - strCarYear) * 2000;
nReturn -= nDepreciation;
return Math.Max(0, nReturn);
}
以上为CarService.cs代码(web service函数)现在报的错是Default.aspx中 requestValue = CarService.GetCarValue这个函数CarService未定义
怎么解决
解决方案 »
- 如何在asp.net后台用javascript给前台"非服务器"控件赋值?
- SQL排序的问题。。。
- 正则表达式提取字符串,高手帮忙解决下
- 删除dgManager中一条记录,id所在列是1,即Columns[1],点击删除后不成功,提示下面错误,是为何?
- 大家看看,怎么把后台的变量的值赋值给前台JS的变量,,,立刻给分!!!我的信用,大家看着办
- 请问各位,如在asp.net中让数据按照时间的先后顺序排列呢?
- 唉,关于框架的问题,怎么实现框架中阻止后退功能。
- VS2003 能够安装在VISTA 下面吗
- 日历控件问题`如何控制他出现的位置并把值按中国的时间格式放进去啊`
- 就一行代码,请赐教
- 大家帮估算下这样一个论坛值多少钱
- 快来,看看我这个<a>加runat=server以后怎么绑定呢?
Atlas基础教程