Logo 
Search:

Asp.net Answers

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds
  Question Asked By: Tye Thompson   on Jul 01 In Asp.net Category.

  
Question Answered By: Melissa King   on Jul 01

The difference from where the generated  script is placed in the from

RegisterClientScriptBlock places the code  just after the opening tag of
the page's object's <form runat=server>element.

RegisterStartupScript emits the script just before the closing tag of
the page  object's </form>

Startup scripts are intended to load  those client scripts where you want
immediate script action when the form  has completed loading in the
browser. If these scripts were placed in the RegisterClientScriptBlock,
the page elements the client script may want to interact would not be
present on the page. Most times, I opt for the Startup method.

Using these register methods ensures that script code gets written to
the page only once. You would not have this protection with the literal
method of writing the script to the page.

Another common gotcha when client scripting is that if <asp:<elements>
have the visible property set to false, they are not rendered on the
html page and as such can not be referenced from script code. A
work-arround is to leave the visible property set to true and then add
the attribute("style", "display:none;").

As always, learnasp.com is an excellent source of reference with links
to many asp.net related topics.

Share: 

 

This Question has 3 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Problem with Focusing the Text box on Page Load Or get search suggestion and latest updates.


Tagged: