. Net uses static refresh controls ScriptManager and UpdatePanel. How can this problem be solved in the pop-up window?
If ScriptManager is used on the page and an update panel is added, the pop-up dialog box on the client does not work.
For example:
Page. ClientScript. RegisterStartupScript (this. GetType (), "", "<script> alert ('information added successfully! '); </Script> ");
This statement is ineffective.
The following steps are required:
ScriptManager. RegisterStartupScript (this. btnOK, this. GetType (), "alert", "alert ('added information successfully! '); ", True );
The first parameter: Which button is used for this JS.
Last parameter: true is used, so the preceding js cannot be added </script>. An error occurs when you add an ECS instance.
The pop-up window in UpdatePannel is written as follows:
String cstext1 = String. Format ("alert ('{0}');", "1233 data records found! ");
ScriptManager. RegisterClientScriptBlock (UpdatePanel1, UpdatePanel1.GetType (), "message", cstext1, true );
. Net pop-up box to summarize vkesoft.com
In the. net web application pop-up message box, I have successfully tested the following methods. If you have other methods, I hope you will not give me any further advice.
1. Only the prompt message is displayed.
Method 1:
String script = "<script> alert ('deleted successfully! ') </Script> ";
Page. RegisterStartupScript ("", script );
Method 2:
Response. Write ("<script> alert ('deleted successfully! ') </Script> ");
Method 3:
Same as method 1 below.
2. You need to confirm the pop-up message.
Method 1:
Add reference System. Windows. Forms. dll
Add the namespace using System. Windows. Forms; (then you may need to regenerate the file)
Then it is the same as MessageBox in Winform (MessageBox. Show (parameter 1 ,......));
Example: if (MessageBox. Show ("are you sure you want to delete? "," Prompt ", MessageBoxButtons. YesNo, MessageBoxIcon. Information) = DialogResult. Yes) {} else {}
Method 2:
Add a new property for the button in Page_load () or elsewhere:
BtnDeleteAdmin. Attributes. Add ("onclick", "return confirm ('Are you sure you want to delete it? ')");
This problem is often encountered: Response is used. the write () method often changes the page layout because the script changes the CSS style of the layout. You can use the client to register the script. This will solve the page variant problem!
Summary of various ways to open a new page
Recommended Methods
[1] Page. RegisterStartupScript ("ServiceManHistoryButtonClick", "<script> window. open ('" + url + "'); </script> ");
[2] Page. RegisterStartupScript ("", "<script> alert ('vote successful. Thank you for your participation! ') </Script> ");
[0] The most common open method
Response. Write ("<script language = 'javascript '> window. open ('" + url + "'); </script> ");
[1] switch directly to the new page, and the original window is replaced;
Response. Redirect ("XXX. aspx", true)
[2] The original window is retained, and a new page is added;
Response. Write ("<script> window. open ('xxx. aspx ',' _ blank ') </script> ")
[3] open a new page, and the original window is replaced;
Response. Write ("<script> window. location = 'xxx. aspx '</script> ")
[4] open a new page;
Server. Transfer ("XXX. aspx ")
Note: It is often used for page jumps that pass session variables!
[5] The original window is retained and a new window is opened in a dialog box;
Response. Write ("<script> window. showModelessDialog ('xxx. aspx ') </script> ")
[6] dialog box to open a new window, the original window is replaced;
Response. Write ("<script> window. showModelDialog ('xxx. aspx ') </script> ")
[7] Open a concise window
Respose. write ("<script language = 'javascript '> window. open ('"+ url +"', '', 'resizable = 1, scrollbars = 0, status = 1, menubar = no, toolbar = no, location = no, menu = no'); </script> ");