2011-11-28 69 views
0

我有以下的Javascript:ICallbackEventHandler,RaiseCallbackEvent不點火

 function processText(n) 
     {     
      CallServer("1" + n.id + "&" + n.value, ""); 
     } 

     function ReceiveServerData(arg, context) 
     { 
      alert(arg); 
     } 

有了這個對我的代碼隱藏:

protected void Page_Load(object sender, EventArgs e) 
    { 
     ClientScriptManager cm = Page.ClientScript; 
     String cbRef = cm.GetCallbackEventReference(this, "arg", "ReceiveServerData", "context"); 

     String callbackscript = "function CallServer(arg, context) {" + cbRef + "; }"; 
     cm.RegisterClientScriptBlock(this.GetType(), "CallServer", callbackscript, true); 

     if (Request.QueryString["stationID"] != null) 
     { 
      isIndividual = true; 
      stationID = Request.QueryString["stationID"]; 

      EncodeDecode objServers = new EncodeDecode(HttpContext.Current.Server.MapPath("~/App_Data/")); 

      if (!IsPostBack) 
      { 
       List<IServerConfig> serverConfig = objServers.GetServerConfiguration(stationID); 
       Session["ServerConfig"] = serverConfig; 
       Session["dctPropertyControls"] = new Dictionary<string, PropertyObj>(); 
      } 

      BindDynamicControls(Session["ServerConfig"] as List<IServerConfig>); 
     } 
    } 

    public void RaiseCallbackEvent(String eventArgument) 
    { 
     int iTyped = int.Parse(eventArgument.Substring(0, 1).ToString()); 

     if (iTyped != 0) //Process Text Fields 
     { 
      string controlName = eventArgument.Substring(1, eventArgument.IndexOf("&")).ToString(); 
      string controlValue = eventArgument.Substring(eventArgument.IndexOf("&")).ToString(); 
      //Txtid += -1;     

      Dictionary<string, PropertyObj> dctPropertyObj = Session["dctPropertyControls"] as Dictionary<string, PropertyObj>; 
      PropertyObj propertyObj = dctPropertyObj[controlName]; 
      propertyObj.property.SetValue(propertyObj.owner, controlValue, null);     

      this.sGetData = "Done"; 
     } 
    } 

    public String GetCallbackResult() 
    { 
     return this.sGetData; 
    } 

processText被炒魷魚和作品,但是RaiseCallbackEvent永遠不會觸發。有任何想法嗎?

回答

0

顯然,任何形式的驗證錯誤都會導致這種情況,儘管頁面不會告訴您。就我而言,我在頁面上有兩個具有相同ID的數據列表。我不得不調試JavaScript並閱讀xmlRequest以查看錯誤。

0

很抱歉,如果答覆晚,但可以幫助別人..

ValidationRequest="false"在.aspx頁面中可以理清這個身份不明的問題。