是一个c#的ajax框架下的使用
JS调用webseverice
在C#后台有一个函数 返回一个string类型
在前台用js调用
得到后台传递过来的值我用 以下方法可以弹出结果
function onmouseout_setFlname()
{
ret=domes.Add_Friend_Type(document.all.set_name.value,doinsert_type);
}function doinsert_type(arg)
{
alert(arg);
}但是我向直接这样弹出function onmouseout_setFlname()
{
ret=domes.Add_Friend_Type(document.all.set_name.value);
alert(ret);//怎么弹出这个值
//domes.Add_Friend_Type 是调用的一个C#函数 返回的类型是string
}标示部分 无法弹出 请高手给出以上方法的解决方法 多谢
JS调用webseverice
在C#后台有一个函数 返回一个string类型
在前台用js调用
得到后台传递过来的值我用 以下方法可以弹出结果
function onmouseout_setFlname()
{
ret=domes.Add_Friend_Type(document.all.set_name.value,doinsert_type);
}function doinsert_type(arg)
{
alert(arg);
}但是我向直接这样弹出function onmouseout_setFlname()
{
ret=domes.Add_Friend_Type(document.all.set_name.value);
alert(ret);//怎么弹出这个值
//domes.Add_Friend_Type 是调用的一个C#函数 返回的类型是string
}标示部分 无法弹出 请高手给出以上方法的解决方法 多谢
解决方案 »
- ie浏览器屏蔽不接受文件夹拖拽功能
- 关于百度弹出层popup.js的问题,路过的看下,谢谢~~~~~
- 拜求!http://www.xunlei.com/中的效果
- 关于cookie在javascript和vbscript交互时偶又遇上一个致命的问题。
- 好心人贴一下javascript中所有对象的属性和方法吧!
- 如何得到页面上具有当前焦点的输入框的名字?(好几个问题要问)
- 请问:如何用javascript实现一个静态的树呢?
- java script 数组?
- 我是入门者,请问JScript和JavaScript一样吗?
- 如何在html中读入一篇word文档
- javascript能否得到鼠标右键点击下的元素(对象)属性
- 关于javascript中的return的问题,请大家关注一下,谢谢!
public string ret="";在你调用的C#函数中:
ret=你想要的值;
前台:
alert(<%=ret%>)
-------------------------------------------------------------------------<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>yoyobeyond</title>
<script language="javascript" type="text/javascript">
<!--function Button1_onclick() {
var ret = SimpleService.SayHello(document.getElementById('Text1').value,document.getElementById('Text1').value, OnComplete, OnTimeOut, OnError);
document.getElementById('Button1').disabled = true;
return(true);
}
function OnComplete(arg) {
alert(arg);
document.getElementById('Button1').disabled = false;
}function OnTimeOut(arg) {
alert("TimeOut encountered when calling Say Hello.");
document.getElementById('Button1').disabled = false;
}function OnError(arg) {
alert("Error encountered when calling Say Hello.");
document.getElementById('Button1').disabled = false;
}
// -->
</script>
</head>
<body style="text-align: center">
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<asp:ServiceReference Path="SimpleService.asmx" />
</Services>
</asp:ScriptManager>
</form>
</body>
</html>----------------------------------------------------------------
simplewebservice.asmx代码:using System;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
/// <summary>
/// Summary description for SimpleService
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService()]
public class SimpleService : System.Web.Services.WebService { public SimpleService () { //Uncomment the following line if using designed components
//InitializeComponent();
} [WebMethod]
public string SayHello(String Name,String Content) {
return "Hello : " + Name + @"" + Content;
}
}
还是用了令一个函数取得结果function OnError(arg) function OnComplete(arg)
function OnTimeOut(arg)
我向直接道道结果 不用令一个函数