Compile the WebProgramSometimes we want a prompt dialog box to pop up when the program is running, for example, to tell the user that the registration has been successful or failed, or some error operation prompts and confirmation prompts when the information is modified.
In the window program, we can use MessageBox. show ("...... ") to implement these functions, but it cannot be done in the Asp.net program. In this case, a better way is to insert the Javascript script language for implementation.
There are three methods of dialog box in Javascript script language:
1: alert is a dialog box with only the "OK" button.
In Asp.net, you can use response. Write ("<SCRIPT> alert ('content prompted on the dialog box ') </SCRIPT> ");
2: Confirm, usually used for confirmation, returns true or false, so it can be easily used for if... else... judgment
It is a mode dialog box with the "OK" button and "cancel" button. This dialog box is very important in some scenarios. It can be used in two ways.
In Asp.net, there are two ways to add a dialog box: the two methods I use are implemented by adding attributes to the button, because during my application, A confirmation prompt is displayed after you click a button.
In the page_load () event, add the following attributes to the button for confirmation:
Button. Attributes. Add ("onclick", "Return getconfirm ();");
Open the. ascx file corresponding to this page, switch to HTML, and add the followingCode:
<SCRIPT>
Function getconfirm ()
{
If (confirm ("do you want to perform this operation? ") = True)
Return true;
Else
Return false;
}
</SCRIPT>
The second method is: In the page_load () event, add the attribute to the button that you want to display the confirmation prompt:
Button. Attributes. Add ("onclick", "Return confirm ('do you want to perform this operation? ');");
3: Promote, a dialog box with input, which can return user-filled strings. It is commonly used to insert UBB format images in some message books or forum input content. This type of dialog box is rarely used in Asp.net.