0

I am opening a ShowModalDialog on a button OnClientClick event and the javascript for it is:-

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

On the Clock.aspx page i have a asp button on which i had written code :-

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 every thing is working fine and this code is working as per my requirement. Just i had added Scriptmanager on the Clock.aspx as i m showing a clock which shows the elapsed time to the user. After that when i m clicking on the btn_Stop on CLock.aspx page i am getting this error message:-"Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed."

Please guide me that how i solve this issue.

I found that what is the root cause of this error. It is happening because i m using Resonse.Write and other information is Here

Guide me that how i fix this as i want to close the webpage after button click event.

1 Answer 1

1

I had Used

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

in place of

Response.Write("<script language='javascript'>window.close();</script>"); Response.End(); and this helps me to fix the error.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.