Use onprerender to output scripts

Source: Internet
Author: User
I need to output a script control display on the front-end. I use onprerender, but I find that the output is on the HTML page.
Previously, the object cannot be found.
The example I see is used to output the Script Function and then trigger the script on the page.
Http://dotnet.chinaitlab.com/ASPNET/39433.html

1
2 # Region Override onprerender pre-generate the output HTML Script
3
4 # Region Override onprerender
5 ///   <Summary>
6 /// Overload the pre-generation method to generate the description border content of the page
7 ///   </Summary>
8 ///   <Param name = "E"> </param>
9 Protected   Override   Void Onprerender (eventargs E)
10 {
11 Base . Onprerender (E );
12 If (Viewstate [ " Edit " ] ! = Null )
13 {
14 Renderjavascript ();
15 This . Viewstate [ " Edit " ] =   Null ;
16 }
17 }
18 # Endregion
19
20
21 # Region Script Definition
22 Private   Const   String Switch_script_id = " {29fd7a41-49fd-4fc4-afa9-6a0b875a1a51} " ;
23
24 Private   Const   String Switch_script = " <Script language = \ " Javascript \ " > \ Ndocument. getelementbyid (\ " Groupedit \ " ). Style. Display = \ " \ " ; \ N " +
25 " Document. getelementbyid (\ " Grouplist \ " ). Style. Display = \ " None \ " ; </SCRIPT> " ;
26
27 Protected   Void Renderjavascript ()
28 {
29 If ( ! This . Isclientscriptblockregistered (switch_script_id ))
30 {
31 This . Registerclientscriptblock (switch_script_id, String . Format (switch_script, Base . ID ));
32 }
33
34 }
35 # Endregion
36
37 # Endregion
38

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.