for closing the webform

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • malli kai
    New Member
    • Sep 2011
    • 6

    for closing the webform

    hi.........
    i want to close the webform in asp for that i write this code....in close button click

    Code:
    protected void Button6_Click(object sender, EventArgs e)
        {
            Response.Write("<script              language='javascript'>window.open('','_self',''); window.close();</script>");
        }

    then i got this error.....
    Error: Sys.WebForms.Pa geRequestManage rParserErrorExc eption: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write( ), response filters, HttpModules, or server trace is enabled.
    Details: Error parsing near '<script language='ja'.

    please anyone help me......
    i am new to asp.net....
    please clear my error.....

    Thanks in advance......
    Last edited by Meetee; Oct 31 '11, 11:56 AM. Reason: code tags added
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Well that's because you're using Response.Write in your C# code.
    When you do this, the text is inserted at a random place in the HTML that it sent to the browser. It is typically inserted before the <body> or <head> tags and so your HTML becomes invalid.

    It sounds like you are using Ajax on your page, so I suggest that you register the script that closes the window with your ScriptManager to get around the problem.

    -Frinny

    Comment

    Working...