In asp.net use JavaScript to display the Information window, you can download a DLL from the Insus.net blog and place it in the site's Bin directory.
Download Address
Create an ASPX page, and then do several actions in the. Aspx.cs, one is to reference the namespace, instantiate the object.
Then write the JavaScript script in the Page_Load event:
Copy Code code as follows:
protected void Page_Load (object sender, EventArgs e)
{
String message = "Welcome, insus.net!";
StringBuilder sb = new StringBuilder ();
Sb. Append ("Window.onload=function () {");
Sb. Append ("alert (')");
Sb. Append (message);
Sb. Append ("')};");
Js. Runjavascript (sb.) ToString ());
}
When a Web page is Page_Load, or when a Web page reloads, it displays a small window of information that results:
Next, Insus.net implements another situation, that is, when the user clicks the Ammonium button, the prompt window is displayed.
We put a button on the Web page:
Copy Code code as follows:
<asp:button id= "Button1" runat= "Server" text= "Submit" onclick= "Button1_Click"/>
Write the onclick event in. Aspx.cs:
Copy Code code as follows:
protected void Button1_Click (object sender, EventArgs e)
{
String message = "Processing your request."
StringBuilder sb = new StringBuilder ();
Sb. Append ("alert (')");
Sb. Append (message);
Sb. Append ("');");
Js. Runjavascript (sb.) ToString ());
}
Try to run a look:
The final example is when a user clicks on the Ammonium button to make a confirmation prompt, which is a choice. After confirmation, the data is not actually submitted or processed.
The way to implement this is to write the following code in the Page_Load event on top of the second example environment above:
Copy Code code as follows:
View Code
protected void Page_Load (object sender, EventArgs e)
{
String message = "Do you want to submit it?" ";
StringBuilder sb = new StringBuilder ();
Sb. Append ("return confirm");
Sb. Append (message);
Sb. Append ("');");
Clientscript.registeronsubmitstatement (this. GetType (), "Alert", sb. ToString ());
}
Get the final effect: