2012-07-12 150 views
0

我上的一個按鈕的OnClientClick事件打開ShowModalDialog的,併爲它的JavaScript是: -JavaScript錯誤:從服務器收到的消息無法解析

<script language="javascript" type="text/javascript"> 
     function openmodalWinLunch() { 
      var variable1 = "Lunch"; 
      window.showModalDialog("ClockPopUP.aspx?code=" + variable1, "dialogWidth:290px;dialogHeight:270px,"); 
     } 

在Clock.aspx頁我有我寫的代碼ASP按鈕: -

protected void btnStop_Click(object sender, EventArgs e) 
    { 
     _nonProduction = new NonProduction(); 
     if (Session["LastNonProdTimeID"] == null) 
     { 
     } 
     else 
     { 
      int NonProdTimeEntryID = Convert.ToInt32(Session["LastNonProdTimeID"]); 
      //Updating the TimeSpent 
      isTimeSpentUpdated = _nonProduction.UpdateTimeSpentInDB(NonProdTimeEntryID); 
      if (isTimeSpentUpdated == true) 
      { 

       string timespent = Convert.ToString(_nonProduction.GetTimeSpent(NonProdTimeEntryID)); 
       //string msg = "Total time consumed in " +HiddenTaskname.Value.ToString()+": " + timespent.ToString() + " Minutes"; 
       Response.Write("<script language='javascript'>window.close();</script>"); 
       Response.End(); 

      } 
      else 
      { 
      } 
     } 



    } 

Preveously每一件事情是工作的罰款,該代碼工作按我的要求。只是我在Clock.aspx上添加了Scriptmanager,因爲我正在顯示一個顯示用戶已用時間的時鐘。之後,當我點擊CLock.aspx頁面上的btn_Stop時,我收到以下錯誤消息: - 「Microsoft JScript運行時錯誤:Sys.WebForms.PageRequestManagerParserErrorException:從服務器收到的消息無法解析。」

請指導我如何解決這個問題。

我發現這個錯誤的根本原因是什麼。這是因爲我使用Resonse.Write和其他信息是Here

指導我如何解決這個問題,因爲我想關閉按鈕點擊事件後的網頁。

回答

1

我已經到位的

Response.Write("<script language='javascript'>window.close();</script>"); Response.End(); 使用

ScriptManager.RegisterStartupScript(Page, GetType(), "CLOSE", "window.close();", true);

,這幫助我修正這個錯誤。

+0

好,.......... – 2012-07-12 06:14:18

相關問題