Click here to Skip to main content
16,021,125 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
I am opening a ShowModalDialog on a button OnClientClick event and the javascript for it is:-
JavaScript
<script language="javascript" type="text/javascript">
        function openmodalWinLunch() {
            var variable1 = "Lunch";
            window.showModalDialog("ClockPopUP.aspx?code=" + variable1, "dialogWidth:290px;dialogHeight:270px,");
        }
</script>

On the Clock.aspx page i have a asp button on which i had written code :-
C#
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
            {
            }
        }
    }

Previously 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.
Posted
Updated 11-Jul-12 19:29pm
v3
Comments
Member 9874029 14-Mar-13 0:59am    
hi i have a similar kind of issue.
i was using a window.showModalDialog() method in javascript to open a pop up and the when it closes the return values are a used to populate some text boxes and then i called document.getElementById('#<%=ID%>').click() To call the Method on the server side it worked fine until i added the script manager. Once i added the scriptmanager It started throwing an error-->"Microsoft JScript runtime error: Sys.ParameterCountException: Parameter count mismatch." i am not understanding how to fix it can anybody help me figure out this issue or somehow work arround it?
Dharmenrda Kumar Singh 14-Mar-13 1:06am    
Please use the below line and try.
ScriptManager.RegisterStartupScript(Page, GetType(), "CLOSE", "window.close();", true);

I Had Used:-
C#
ScriptManager.RegisterStartupScript(Page, GetType(), "CLOSE", "window.close();", true);

in Place of
C#
Response.Write("<script language='javascript'>window.close();</script>"); Response.End()

and this helps me to fix the error.
 
Share this answer
 
Comments
Member 9874029 14-Mar-13 1:02am    
hi i have a similar kind of issue.
i was using a window.showModalDialog() method in javascript to open a pop up and the when it closes the return values are a used to populate some text boxes and then i called document.getElementById('#<%=ID%>').click() To call the Method on the server side it worked fine until i added the script manager. Once i added the scriptmanager It started throwing an error-->"Microsoft JScript runtime error: Sys.ParameterCountException: Parameter count mismatch." i am not understanding how to fix it can anybody help me figure out this issue or somehow work arround it?
Dharmenrda Kumar Singh 14-Mar-13 1:07am    
Please use the below code:-
ScriptManager.RegisterStartupScript(Page, GetType(), "CLOSE", "window.close();", true);
 
Share this answer
 
Comments
Member 9874029 14-Mar-13 1:02am    
hi i have a similar kind of issue.
i was using a window.showModalDialog() method in javascript to open a pop up and the when it closes the return values are a used to populate some text boxes and then i called document.getElementById('#<%=ID%>').click() To call the Method on the server side it worked fine until i added the script manager. Once i added the scriptmanager It started throwing an error-->"Microsoft JScript runtime error: Sys.ParameterCountException: Parameter count mismatch." i am not understanding how to fix it can anybody help me figure out this issue or somehow work arround it?
 
Share this answer
 
Comments
Dharmenrda Kumar Singh 12-Jul-12 1:31am    
As per the link i understand that the Error is occuring because i m using Resonse.Write on the button click but i want to close the webpage after button click event.So guide me that how i proceed to fire javascript without using Response.Write.
Member 9874029 14-Mar-13 1:02am    
hi i have a similar kind of issue.
i was using a window.showModalDialog() method in javascript to open a pop up and the when it closes the return values are a used to populate some text boxes and then i called document.getElementById('#<%=ID%>').click() To call the Method on the server side it worked fine until i added the script manager. Once i added the scriptmanager It started throwing an error-->"Microsoft JScript runtime error: Sys.ParameterCountException: Parameter count mismatch." i am not understanding how to fix it can anybody help me figure out this issue or somehow work arround it?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900