Functional Requirements : Use the ImageButton control in the framework to close the application query "confirm Exit" and invoke JavaScript in ImageButton's OnClick event (C #) to shut down ie.
Issue : Pop-up dialog box, you will lose the contents of the child interface, even if you do not exit the system, can not return to the original state.
solution : Do not use the ImageButton OnClick event (C #) directly, but through the way of ImageButton's Attributes.Add ("OnClick", "javascript: ..."), will be able to solve the problem.
1. aspx file:
Copy Code code as follows:
<!--aspx file-->
<asp:imagebutton id= "Imagebutton_close" runat= "Server" imageurl= "~/images/icons/stop.gif"/>
2. C # files:
Copy Code code as follows:
. cs Files
Adding events, running JavaScript code
protected void Page_Load (object sender, EventArgs e)
{
if (! IsPostBack)
{
IMAGEBUTTON_CLOSE.ATTRIBUTES.ADD ("OnClick", "Javascript:if" (confirm) (' Try it, can it succeed? ') return false; ");
}
}