dhtml| Skills | Web page ASP. NET changes our programming method, makes the development BS program simpler. However, if the use of server controls is bound to lead to frequent web page submissions, the operation is extremely unfriendly, but also increased the burden on the server. Some of the necessary validation work is done on the client, only when the validation is submitted, you can significantly reduce the number of page refreshes.
For example, when we press the "delete" button, we first confirm it on the client: a dialog box that pops up "if you really want to delete." When the user presses "yes" to commit to the server to execute the removal program. If no is pressed, the commit action of the thread is terminated. Commit is not to be done too much to consider, because the server's button control is going to be done automatically, and now I'll introduce you to terminate the submission method:
in DHTML, each event can be processed with return False to terminate the execution of the thread action. such as <body OnContextMenu = "Javascript:return false;" > You can disable the right-click menu on the page. For the server button, we can add an onclick property to the Pageload server at the first load time to perform the client corner: this. DELBUTTON.ATTRIBUTE.ADD ("OnClick", "Javascript:return delconfirm ();"); When the user presses the Delete button, it executes the customer's delconfirm () function first. Note: The Javascript:return of the red font (used to receive the return result of the function) and the; (the button's submit action will be registered in the form of a corner), it is necessary if you do not use the number to separate the resulting grammatical errors. In the client's function, there must be a return result, where returns false, the subsequent corner of this operation will be terminated, and the other return results will continue to execute.
the complete method for deleting the processing is as follows:
Server side:
private void Page_Load ()
{
...
if (!this. IsPostBack)
{
...
this.delButton.Attribute.Add ("OnClick", "Javascript:return delconfirm ();");
...
}
...
}
...
private void Delbutton_click (object sender, EventArgs e)
{
...
}
...
Client:
...
<script language=javascript>
function delconfirm ()
{
return confirm ("Do you really want to delete it?");
}
</SCRIPT>
...