开发者

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 ident开发者_如何学运维ify 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜