var a = document.getElementById("<%=TxtErrorId.ClientID %>").value;
         if (a == null) {
             a = 10;
         }         var s = '<%=BindAllModel("' +a+ '") %>';
我这么做为什么每次a都是空值
后台方法 public string BindAllModel(string id)

解决方案 »

  1.   


    <html xmlns="http://www.w3.org/1999/xhtml">
    <head> 上方的此句要保留var a = document.getElementById("<%=TxtErrorId.ClientID %>").value;
      if (a == null) {
      a = 10;
      }
      alert(a); //输出一下a的值
      var s = '<%=BindAllModel("' +a+ '") %>';
      alert(s);
      

  2.   

    http://www.cnblogs.com/morningwang/archive/2008/04/07/1140340.html
      

  3.   

    你要分清楚,js是后执行的,cs 代码是先执行的
      

  4.   

    =要实现回调,你需要实现System.Web.UI.ICallbackEventHandler接口参考
    http://msdn.microsoft.com/zh-cn/library/ms178208%28VS.80%29.aspx
      

  5.   

    出现输入字符串不正确的错误,跟踪获取的id值为"'+a+'"为空,怎么回事
      

  6.   

    楼主把时空都搞错乱了. 
    你最好说明一下你的目的如果只是要让代码能正确运行var a = document.getElementById("<%=TxtErrorId.ClientID %>").value;
      if (a == null) a = 10;
    var s = '<%=BindAllModel(TxtErrorId.Value) %>';
    alert("a是"+a);
    alert("s"是+s);
      

  7.   

    alert("s"是+s);改为alert("s是"+s);
      

  8.   

    function bbbb()
    {
      var a = "xxxx";
      var s = '<%=getc#("'+a+'") %>';
      alert(s);
    }
      

  9.   

    楼主应该仔细看看asp.net生命周期
      

  10.   

    Ajax,jq,或者手写的Ajax都是可以实现的哦
      

  11.   

    ASP.NET ajax接口实现下, javascript异步调用;
    混写代码有时也行.