2012-07-12 143 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

相关问题