HOW CAN YOU TO ADD JAVASCRIPT TO A PAGE WHEN PERFORMING AN ASYNCHRONOUS POSTBACK?

Amit Singh

Total Post:565

Points:2825
Posted by  Amit Singh
AJAX 
 1524  View(s)
Ratings:
Rate this:
  1. Amit Singh

    Post:565

    Points:2825
    How can you to add JavaScript to a page when performing an asynchronous postback?

    Use the ScriptManager class. This class contains several methods like the RegisterStartupScript(), RegisterClientScriptBlock(), RegisterClientScriptInclude(), RegisterArrayDeclaration(),RegisterClientScriptResource(), RegisterExpandoAttribute(), RegisterOnSubmitStatement() which helps to add javascript while performing an asynchronous postback.

  1. Varun Agrawal

    Post:159

    Points:795
    How can you to add JavaScript to a page when performing an asynchronous postback?

    For all three, a script element is rendered after the opening form tag. Following are the differences:
    1 - RegisterClientScriptBlock - The script is specified as a string parameter.
    2 - RegisterClientScriptInclude - The script content is specified by setting the src attribute to a URL that points to a script file.
    3 - RegisterClientScriptResource - The script content is specified with a resource name in an assembly. The src attribute is automatically populated with a URL by a call to an HTTP handler that retrieves the named script from the assembly.

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!