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