C # The difference between RegisterStartupScript and registerclientscriptblock that synchronizes or asynchronously registers JavaScript to a page from background code

Source: Internet
Author: User

Here is the difference between synchronous registration JS and asynchronous Registration JS

Synchronous Registration JS:registerclientscriptblock, equivalent to the beginning of the form (immediately after the


Asynchronous registration JS:registerstartupscript, a script block is sent at the end of the form (before the identity), executed after the document is loaded, and equivalent to the contents of Body.onload=f () {}. To wait until the HTML node element render is complete before loading JS

stringScript ="var iseteditinputrealonly;function seteditinputrealonly () {$ (' input[type=text],textarea,select '). attr (' Disabled ', ' disabled '); $ (' table[class=edittable][projectcurrencyexchangerate=1] '). FIND (' img '). Hide (); $ (' table[ Class=edittable][projectcurrencyexchangerate=1]. Find (' tr[class=head] '). Find (' div '). EQ (0). Hide (); $ (' #ctl00_ Body_cycleandscenario_ddlcycle, #ctl00_body_CycleAndScenario_ddlScenario '). Removeattr (' disabled '); if ($ (' table[ Class=edittable][projectcurrencyexchangerate=1] '). FIND (' img '). length>0) {clearinterval (iseteditinputrealonly )}$ (' input[type=submit] '). Click (Function (Event) {$ (' #divImgWait '). Hide (); Event.preventdefault ()})}$ (document). Ready (function () {Iseteditinputrealonly=setinterval (' seteditinputrealonly () ', +)});"; //registering JavaScript asynchronouslySystem.Web.UI.ScriptManager.RegisterStartupScript (Context.page, ((syspage) context.page). GetType (), Guid.NewGuid (). ToString (), script,true); //Register JavaScript synchronouslyPage.ClientScript.RegisterClientScriptBlock (Context.page, ((syspage) context.page). GetType (), Guid.NewGuid (). ToString (), script,true);

C # The difference between RegisterStartupScript and registerclientscriptblock that synchronizes or asynchronously registers JavaScript to a page from background code

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.