Sometimes I want to pop up a message in the client to prompt the user, not simply print a prompt message on the page, so that the page is not beautiful. The method of implementing the client pop-up message is simple, mainly binding events to buttons, or it can be implemented like MessageBox as in WIN FORM.
¹¹ With the button's Attribute property, the idea is to bind a Click event of the button with a JavaScript code.
?????: this.button1.attributes ["onclick"] = "JavaScript: return" ";
The front part of this code is this.button1.attributes ["onclick] this refers to the click attribute of the button, and the rear section refers to the trigger processing of the Click event, using a JavaScript script.
2 The second method is similar to the first, as follows:
Webform1.aspx.cs: this.button1.attributes.add ("onclick", "javascript: return test ()");
????? Webform1.aspx :?
?????????????????????????
??????????????????????????????????? script>
This method mainly binds the OnClick event to a JavaScript function written in the ASPX page.
3 said earlier, in Web Form, you can also be implemented using MessageBox as in Win Form. You need to import System.Window.Form names before using MessageBox, then you can use it as used in Win Form.
The .NET provides these very simple processing methods, which greatly improves development efficiency.
Posted on August 03, 2004 10:18 PM