点击一个HTML的BUTTON 调用服务端事件,我用的是AjaxPro.2.dll,比如 <input id="Button2" type="button" value="button" onclick="tj();" /><script language="javascript">
  function tj()
  {Telesa.tijiao();
  }
  </script>后台:已注册好,引用好  [AjaxPro.AjaxMethod]
    public void tijiao(string str)
    {
         Response.Write("11");//这句效果不能实现
          Label1.Text="22";//也不能
    }

解决方案 »

  1.   

    前台调用后台啊,你可以这样的:
    放一个button按钮ID为btnLogin,按钮下写好事件,将按钮设为隐藏,前台js代码里写函数:  
    function tj() 
      { 
       document.getElementById("btnLogin").click();
      } 
      </script> 
      

  2.   

    public  class AjaxMethod
        {
             public static DataSet GetCountryList()
            {
                DataSet ds = new DataSet();
                
                return ds;
            } [Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.Read)]
            public DataSet GetProvinceList(string strCountry)
            {
           }
     function ProResult() 

    var city=document.getElementById("ddl_country");
    AjaxMethod.GetProvinceList(city.value,get_pro_Result);
    }
    或通过web servicea输出值
    public class RegistValidate : IHttpHandler {
        
        public void ProcessRequest (HttpContext context) {
            context.Response.ContentType = "text/plain";
            string username = HttpUtility.UrlDecode(context.Request.QueryString["username"].ToString());
          
            DataSet ds ;
            if (ds.Tables[0].Rows.Count > 0)
            {
                context.Response.Write("该用户名已经有人使用!" + username);
            }
            else
            {
                context.Response.Write("可以使用!" + username);
            }
            ds.Dispose();
            System.Threading.Thread.Sleep(1000);
        }
     
        public bool IsReusable {
            get {
                return false;
            }
        }}
      

  3.   

    楼主你的情况是正常的,这个AjaxPro就是用来跟服务器交换数据的,跟服务端有关的东西都不能使用。我以前用的时候出现的问题跟你一模一样。其实你要让你的Label有值的话,你在客户端用<span />来替代掉这个Label,然后
    [AjaxPro.AjaxMethod] 
        public string tijiao(string str) 
        { 
                     return "22"
        }在后台的js函数用有个你定义的成功的处理函数有个参数result,然后把这个result赋给<span>
      

  4.   

    AjaxPro方法只是用来跟服务器交换数据的,不能作为页面动作来使用
    要操纵页面,使用JavaScript来做,这才是使用ajax中的j即javascript啊
      

  5.   

    简单的要死。用jquery$("#div").load("test.aspx");test.aspx.cs页面
    Response.Write("注册功能");
      

  6.   


      [AjaxPro.AjaxMethod] 
        public void tijiao(string str) 
        { 
            Response.Write("11");//这句效果不能实现 
              Label1.Text="22";//也不能 
        }这样是不行的,你可以返回值的时候再用js操作
      

  7.   

    客户回调实现无刷新二级联动
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="CallBack_Default.aspx.cs" Inherits="CallBack_Default" %><!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>使用.net回调(CallBack)技术实现局部刷新</title>
        <script language="javascript">
            function FillData()
            {
                var city = document.getElementById("TextBox1").value;
                <% =ClientScript.GetCallbackEventReference(this,"city","FillDll",null) %>;
            }
            
             function FillDll(strCity)
            {
               document.getElementById("DropDownList1").options.length = 0;
               var indexofcity;
               var city;
               //分割传递来的字符串
               while(strCity.length>0)
               {
                 //判断是否是最后一个字符串
                 indexofcity = strCity.indexOf(",");
                 if (indexofcity > 0)
                 { 
                   city = strCity.substring(0,indexofcity);
                   strCity = strCity.substring(indexofcity+1);
                   //填充DropDownList1
                   document.getElementById("DropDownList1").add(new Option(city,city));
                 }
                 else
                 {
                   document.getElementById("DropDownList1").add(new Option(strCity,strCity));
                   break;
                 }
               }
            }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <strong>使用.net回调(CallBack)技术实现局部刷新</strong><br />
            城市名称:<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
            <input id="Button1" type="button" value="查 询" onclick="FillData()" /><br />
            城镇:<asp:DropDownList ID="DropDownList1" runat="server">
            </asp:DropDownList></div>
        </form>
    </body>
    </html>public partial class CallBack_Default : System.Web.UI.Page,ICallbackEventHandler
    {
        private string _data;    protected void Page_Load(object sender, EventArgs e)
        {    }    public string GetCallbackResult()
        {
            return _data;
        }    public void RaiseCallbackEvent(string eventArgument)
        {
            switch (eventArgument)
            {
                case "武汉":
                    _data = "武昌,汉口,洪山";
                    break;
                case "钟祥":
                    _data = "郢中,胡集,双河";
                    break;
                default:
                    break;
            }
        }}
      

  8.   

    是可以调用,但是页面刷新了。
    有没有其他好的AJAX框架好实现这个功能?
      

  9.   

     [AjaxPro.AjaxMethod]
      public void tijiao(string str)
      {
      Response.Write("11");//这句效果不能实现
      Label1.Text="22";//也不能
      }这个方法不能分开写么?
    Response.Write() jquery 很容易实现
    Label1.Text="" 这个用javascript实现不行么