Page.ClientScript.RegisterStartupScript (this. GetType (), "", "<script>alert (' Please enter the correct user name and password! ');</script> ");
In the. NET web App pop-up message box, I tried to succeed in the following several, if there are other methods, I hope you do not hesitate to enlighten.
1. Only the prompt message pops up.
Method One:
String script = "<script> alert (' Delete succeeded! ') </script> ";
Page.registerstartupscript ("", script);
Method Two:
Response.Write ("<script>alert (' delete succeeded! ') </script> ");
Method Three:
With the following method one.
2. User-determined pop-up messages are required.
Method One:
Add Reference System.Windows.Forms.dll
Add namespaces using System.Windows.Forms; (then you may need to regenerate the files)
Then the same as the MessageBox in the WinForm (MessageBox.Show (parameter 1, ...));
Example: if (MessageBox.Show ("Are you sure you want to delete? "," hint ", Messageboxbuttons.yesno, messageboxicon.information) = = Dialogresult.yes) {} else{}
Method Two:
Add a new property to the button in the Page_Load () or other appropriate place:
BTNDELETEADMIN.ATTRIBUTES.ADD ("onclick", "return confirm (' Are you sure you want to delete it?") ‘)");
Often the problem is that using the Response.Write () method often results in page layout changes because the script script changes the layout's CSS style and can use the client registration script, which resolves the problem with the page variant!
Summary of various ways to open new pages
Recommended methods of Use
"1" page.registerstartupscript ("Servicemanhistorybuttonclick", "<script>window.open (' + URL +"); </script > ");
"2" Page.registerstartupscript ("", "<script>alert (' vote success, thank you for your participation! ') </script> ");
"0" The most common way to open
Response.Write ("<script language= ' JavaScript ' >window.open ('" + url+ "');</script>");
"1" directly to the new page, the original window is replaced;
Response.Redirect ("Xxx.aspx", True)
"2" The original window is reserved, another new page added;
Response.Write ("<script>window.open (' xxx.aspx ', ' _blank ') </script>")
"3" opens a new page, the original window is replaced;
Response.Write ("<script>window.location= ' xxx.aspx ' </script>")
"4" opens a new page;
Server.Transfer ("xxx.aspx")
Description, often used to pass the session variable page jump!
"5" The original window is reserved, open a new window as a dialog box;
Response.Write ("<script>window.showmodelessdialog (' xxx.aspx ') </script>")
"6" dialog to open a new window, the original window is replaced;
Response.Write ("<script>window.showmodeldialog (' xxx.aspx ') </script>")
"7" Opens the compact window
Respose.write ("<script language= ' JavaScript ' >window.open ('" +url+ "', ' ', ' Resizable=1,scrollbars=0,status=1, Menubar=no,toolbar=no,location=no, Menu=no ');</script> ");
Web Popup dialog box