Web Popup dialog box

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.