when creating a web system for the customer a few days ago, you need to add a "Exit System" connection to the header of each page. A confirmation dialog box is required. Generally, by adding "This. linkbutton. Attributes. Add (" onclick "," javascript: Return confirm ('Are you sure you want to exit the system? ') ")" Script. However, because there are similar prompt boxes on the home page, "htmlfile: pointer invalid" may appear in framwork1.1, And the CSS style cannot be loaded on the whole page.
here is a solution. For details, refer to the following:
1 -- The subcontrol of the custom control (related to Javascript, such as linkbutton lbnquit) can be defined as a public attribute.
2 -- add a reference to the custom space on the page that references the control, for example:
Public bankofchina. usercontorl. header header1;
The custom definition in the HTML file is as follows:
<Uc1: Header id = "header1" runat = "server"> </uc1: Header>
In this way, we define a control similar to webcontrol.
3 -- Add the following statement to the page that references the control:
Header1.lbnquit. Attributes. Add ("onclick", "javascript: Return confirm ('Are you sure you want to exit the system? ');");
4 -- The above event defines the lbnquit function to click the control to bring up the dialog box. At this time, if you "confirm the prompt", you should be able to continue
Do the following, for example:
Session. Clear (); // window. Opener = NULL;
Session ["class"] = "-1 ";
// Response. Write ("<script language = JavaScript> self. Close (); </SCRIPT>"); // This cannot be added
To enable the above execution, we can define a click event
Private void lbnquit_click (Object sender, system. eventargs E)
Summary:
After the above steps, we can implement the following process functions:
The page displays the control --> click the control --> pop-up confirmation dialog box --> confirmation prompt --> execute the defined event processing function --> end
│ Bytes
--------------- Cancel confirmation -----------------------------------
I would like to set it to public static, and then initialize the linkbutton in application_start (). However, I cannot compile the link, but I want to know how to solve it.