Register JavaScript?

Source: Internet
Author: User

See this sentence in the projectCode:

This . Prerender + =   New Eventhandler (pagejs_prerender );

 PrerenderThis is an event.PrerenderAdd a processing method for the event.

RegisterJSExample:

Registerclientscriptblock

///   <Summary>
/// Before the page is displayed, register JavaScript from the server to the front-end html
/// Display the lettertemplateparamerter of the current lettertemplate in the foreground
///   </Summary>
///   <Param name = "sender"> </param>
///   <Param name = "E"> </param>
Protected   Void Pagejs_prerender ( Object Sender, system. eventargs E)
{
System. Text. stringbuilder sb =   New System. Text. stringbuilder ();
SB. append ( " <Script language = \ " Javascript \ " > \ R \ n " );
If (Session [globalpara. seesion_show_alert_message] ! =   Null )
{
SB. append ( " Alert (' "   + Stringutil. jsscriptreplaceillegalstring (string) session [globalpara. seesion_show_alert_message]) +   " '); \ R \ n " );
Session. Remove (globalpara. seesion_show_alert_message );
}
SB. append ( " </SCRIPT> \ r \ n " );
String JS = SB. tostring ();
If ( ! Isclientscriptblockregistered ( " Pagejs_prerender " )) // Register JS
{
Registerclientscriptblock ( " Pagejs_prerender " , JS );
}
}

 Why registerJavascript? RegisterJavascriptWhat does that mean?

AboutRegisterclientscriptblockThe roles are not the same. Some say they are registered from the front-end to the back-end.JavascriptScript, some are registered from the background to the foregroundJavascriptScript.

My understanding of registering Javascript is vague.

 

Supplement:

Public   Static   Void Showerrormsg (page, String Errmsg)
{
String Scrpt =   " <Script language = 'javascript '> "
+   " Alert (' "   + Errmsg +   " '); </SCRIPT> " ;< P>

page. clientscript. registerstartupscript (page. getType (), " clientscript " , scrpt );
}

registerclientscriptblock generally returns the packaging of client functions, registerstartupscript returns the function that will be executed after the document is loaded. It is similar to the function in body onload = "F ()". The two methods have different positions in the Code presented by the client. registerclientscriptblock is after

, while registerstartupscript is before .

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.