Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RegisterClientScriptInclude: What does "type" parameter do?

I'm currently looking into the RegisterClientScriptInclude method so I can be sure that I don't do something like include JQuery twice on one page. The Microsoft documentation states:

This overload of the RegisterClientScriptInclude method takes key and url parameters to identify the script, as well as a type parameter to specify the identification of the client script include. You specify the type based on the object that will be accessing the resource. For instance, when using a Page instance to access the resource, you specify the Page type.

I don't get what that actually does for me. Does it just identify in some way which page/control took precedence and registered the include? Can someone please explain why I would want to provide a type in addition to the key/url? Thanks in advance.

like image 391
Ocelot20 Avatar asked Aug 25 '11 19:08

Ocelot20


1 Answers

The type is used along with the key string to form a unique identifier. This is used to identify the include so that you can call RegisterClientScriptInclude several times with the same script, but it will only be included once in the page.

The type is needed so that controls can work independently of each other within the page. If you have two controls that makes includes that are not aware of each other, they may use the same key string by accident. If the type (in this case the type of the controls) was not used, one include would exclude the other although they were never intended to interfer with each other.

like image 64
Guffa Avatar answered Oct 08 '22 11:10

Guffa