After the submission is successful, the alert dialog box is displayed, using page. clientscript. registerclientscriptblock and direct response. write ("<SCRIPT type = 'text/JavaScript '>" + script + "</SCRIPT> ");
The alert content is displayed. However, the style of the page is changed by using the response method. Unexpected page disorder occurs. The cause is unknown.
Below is a JS group class
Public Class Jshelper { Public Static Httpresponse response { Get { Return Httpcontext. Current. response ;}} /// <Summary> /// This method will inexplicably lose the style if the page has a server text box Control /// </Summary> /// <Param name = "script"> </param> Public Static Void Executescript ( String Script) {response. Write ( " <SCRIPT type = 'text/JavaScript '> " + Script + " </SCRIPT> " );} /// <Summary> /// This method can achieve the expected alert effect without changing the style /// </Summary> /// <Param name = "script"> </param> /// <Param name = "page"> </param> Public Static Void Executescript ( String Script, page) {page. clientscript. registerclientscriptblock ( Typeof (Page ), " MSG " , " <SCRIPT type = 'text/JavaScript '> " + Script + " </SCRIPT> " , False );} Public Static Void Gotourl ( String URL) {response. Write ( " <SCRIPT type = 'text/JavaScript '> top. Location. href =' " + URL + " '; </SCRIPT> " );}}
1. UsePublic Static VoidExecutescript (StringScript) method:
2. UsePublic Static VoidExecutescript (StringScript, page)Method:
The second is normal. The style of the text box is not deformed.