ClientScriptManager.GetWebResourceUrl Method
Assembly: System.Web (in system.web.dll)
public String GetWebResourceUrl ( Type type, String resourceName )
public function GetWebResourceUrl ( type : Type, resourceName : String ) : String
Not applicable.
Parameters
- type
The type of the server resource.
- resourceName
The name of the server resource.
Return Value
The URL reference to the resource.The GetWebResourceUrl method returns a URL reference to a server resource embedded in an assembly. The returned reference is not URL encoded. Resources can be script files, images, or any static file. 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.
A Web resource registered with the page is uniquely identified by its type and name. Only one resource with a given type and name pair can be registered with the page. Attempting to register a resource that is already registered does not create a duplicate of the registered resource.
The GetWebResourceUrl method is used in conjunction with the RegisterClientScriptResource method for accessing resources embedded in assemblies. For more information on using resources in applications, see ASP.NET Web Page Resources Overview.
The following code example demonstrates the use of the GetWebResourceUrl method. The type parameter in this example is set to the type of class in the assembly containing the resource.
The following code example demonstrates how to programmatically apply the WebResourceAttribute metadata attribute to mark the assembly for the resources that will be served.
This example requires a JavaScript file named Script_include.js, with the following contents:
function DoClick() {Form1.Message.value='Text from resource script.'}
Compile the Script_include.js file as a resource in the assembly that contains the Samples.AspNet.CS.Controls.ClientScriptResourceLabel class.