This article is a mirror article of machine translation, please click here to jump to the original article.

View: 16223|Reply: 0

[ASP.NET] ASP.NET Solution to the problem that the CSS style fails, the layout changes, and the page turns white after the alert pop-up dialog box pops up

[Copy link]
Posted on 7/16/2015 5:55:53 PM | | |

asp。 .NET pops up a dialog box from the server to the client, the page turns white, and the layout changes The solution is to add this function to the CS class:

    /// <summary>
        A dialog box pops up
        /// </summary>
        <param name="page"> the page to pop up the dialog box, this page uses this. Page</param>
        <param name="values"> what pops up</param>
        public void WebMessageBox(System.Web.UI.Page page, string values)
        {
            page. Clientscrip removes t.RegisterStartupscrip removes t(page. GetType(), "", "<scrip remove t language=javascrip remove t>alert('" + values + "')</scrip去掉t>");
        }

You can call this function when using it, as follows:

if (string. IsNullOrEmpty(strTemp))
            {
               sc = new StrControl();
               sc. WebMessageBox(this. Page, "Search content cannot be empty");
            }

This way, there will be no whitening of the page and invalidation of CSS styles.

Reason: Because the source code of the page is written like this, the following sentences are added at the end of the page:

   
<scrip remove t language=javascrip remove t>alert('Search content cannot be empty').</scrip去掉t></form>
</body>
</html>



Here's a way to fix page whitening, but the CSS styles break and the result is as follows because the generated page source code is at the very top of the page:

1. Background code
if (string. IsNullOrEmpty(strTemp))
            {
                Response.Write("<scrip remove t >function window.onload() {alert('Search cannot be empty!'); }</scrip去掉t>");
            }

2. Front desk code
<scrip remove t >function window.onload() {alert('Search page cannot be empty!'); } }</scrip去掉t>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>

</title>
<link href="Styles/reset.css" rel="stylesheet" type="text/css" /><link href="Styles/head_css.css" rel="stylesheet" type="text/css" />
    <scrip remove t src="../scrip remove ts/jquery-1.7.2.min.js" type="text/javascrip remove t"></scrip去掉t>
    <scrip remove t src="../scrip remove ts/Default.js" type="text/javascrip remove t"></scrip去掉t>
</head>




Previous:Share several online file characteristics behavior analysis, as well as scan for virus websites
Next:asp.net can't run pop-up js code workaround with ajax
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com