What should you do?

You are implementing custom ASP.NET server controls.
You have a base class named RotaryGaugeControl and two subclasses named CompassGaugeControl and SpeedGaugeControl.
Each control requires its own client JavaScript code in order to function properly.
The JavaScript includes functions that are used to create the proper HTML elements for the control.
You need to ensure that the JavaScript for each of these controls that is used in an ASP.NET page is included in the generated HTML page only once, even if the ASP.NET page uses multiple instances of the given control.
What should you do?

You are implementing custom ASP.NET server controls.
You have a base class named RotaryGaugeControl and two subclasses named CompassGaugeControl and SpeedGaugeControl.
Each control requires its own client JavaScript code in order to function properly.
The JavaScript includes functions that are used to create the proper HTML elements for the control.
You need to ensure that the JavaScript for each of these controls that is used in an ASP.NET page is included in the generated HTML page only once, even if the ASP.NET page uses multiple instances of the given control.
What should you do?

A.
Place the JavaScript in a file named controls.js and add the following code line to the Page_Load method of each control.
Page.ClientScript.RegisterClientScriptInclude(this.GetType(), “script”, “controls.js”);

B.
Add the following code line to the Page_Load method of each control, where strJavascript contains the JavaScript code for the control.
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), “script”, strJavascript);

C.
Add the following code line to the Page_Load method of each control, where CLASSNAME is the name of the control class and strJavascript contains the JavaScript code for the control.
Page.ClientScript.RegisterStartupScript(typeof(CLASSNAME), “script”, strJavascript);

D.
Add the following code line to the Page_Load method of each control, where CLASSNAME is the name of the control class and strJavascript contains the JavaScript code for the control.
Page.ClientScript.RegisterClientScriptBlock(typeof(CLASSNAME), “script”, strJavascript);



Leave a Reply 1

Your email address will not be published. Required fields are marked *


aaa

aaa

A client script is uniquely identified by its key and its type. Scripts with the same key and type are considered duplicates. Only one script with a given type and key pair can be registered with the page. Attempting to register a script that is already registered does not create a duplicate of the script.
Call the IsClientScriptBlockRegistered method to determine whether a client script with a given key and type pair is already registered and avoid unnecessarily attempting to add the script.