In this section you will learn how you would implement this
dialog box into your project. Navigate to a webform, go to its design mode and
paste the HTML code between the <form> tag.
Now create a javascript file called CustomDialog.js in your
application root folder, paste all the JavaScript functions and add the
following code in the <head> section in the HTML.
Listing 7
<script language="javascript" src="CustomDialog.js"></script>
The above code will link the javascript file you already
created to the webform. After this stage, you can add JavaScript code to call
the functions on button click, for example.
Listing 8
<script language = JavaScript>
function ShowMessage()
{
SetText('Yes', 'No');
DisplayConfirmMessage('are you sure', 180, 90)
SetDefaultButton('btnConfOK');
return false;
}
</script>
The first thing you need to do is to set the text to be
displayed on the buttons (I have chosen Yes and No), the second thing is to
display the confirmation message and send the appropriate parameters, the third
thing is to set the default button, in this case I chose the Yes button,
finally the return false is used to cancel the postback.
Now to call this function on button click, add the following
code to the page_load event.
Listing 9
Button1.Attributes.Add("onclick","return ShowMessage()");
Figure 1
The above figure shows the confirmation dialog box when the
user clicks on the Button. Note that this is displayed in the maximized window
size.
Figure 2
The above figure will show the new location of the dialog
box by just resizing the window.