0

我在按钮 OnClientClick 事件上打开一个 ShowModalDialog,它的 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
            {
            }
        }



    }

以前每件事都工作正常,这段代码按照我的要求工作。只是我在 Clock.aspx 上添加了 Scriptmanager,因为我向用户显示了一个时钟,该时钟向用户显示了经过的时间。之后,当我单击 CLock.aspx 页面上的 btn_Stop 时,我收到以下错误消息:-“Microsoft JScript 运行时错误:Sys.WebForms.PageRequestManagerParserErrorException:无法解析从服务器接收到的消息。”

请指导我如何解决这个问题。

我发现这个错误的根本原因是什么。这是因为我正在使用 Resonse.Write 和其他信息在 这里

指导我如何解决此问题,因为我想在按钮单击事件后关闭网页。

4

1 回答 1

1

我用过

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

代替

Response.Write("<script language='javascript'>window.close();</script>"); Response.End(); 这有助于我修复错误。

于 2012-07-12T05:42:12.067 回答