Defines a resource in an assembly to be used from a client script file. This class cannot be inherited.
Syntax
CSharp
VisualBasic
ManagedCPlusPlus
JSharp
Members
Remarks
The ScriptResourceAttribute class is valid only when you use it in assembly declarations. You use it to enable a specified embedded script resource in an assembly. You can define the name of the embedded script library, the name of the resource file for the script library, and the name that is used in a script file for retrieving the resource values. The ScriptManager class uses the properties in ScriptResourceAttribute to determine the correct resource name for a script library. The TypeName property is used with a resource key to specify a resource.
Examples
The following example shows a ScriptResourceAttribute attribute for a script file named CheckAnswer.js that uses resources from the VerificationResources resource files. The name Answer is used to reference these resources.
cs
[assembly: System.Web.UI.WebResource("LocalizingScriptResources.CheckAnswer.js", "application/x-javascript")]
[assembly: System.Web.UI.ScriptResource("LocalizingScriptResources.CheckAnswer.js", "LocalizingScriptResources.VerificationResources", "Answer")]
vb
<Assembly: System.Web.UI.WebResource("LocalizingScriptResources.CheckAnswer.js", "application/x-javascript")>
<Assembly: System.Web.UI.ScriptResource("LocalizingScriptResources.CheckAnswer.js", "LocalizingScriptResources.VerificationResources", "Answer")>
The following example shows how to use the resources in client script. The resource keys (Correct and Incorrect) are prefixed with Answer to identify the script resource definition that contains the values.
cs
function CheckAnswer()
{
var firstInt = $get('firstNumber').innerText;
var secondInt = $get('secondNumber').innerText;
var userAnswer = $get('userAnswer');
if ((Number.parseLocale(firstInt) + Number.parseLocale(secondInt)) == userAnswer.value)
{
alert(Answer.Correct);
return true;
}
else
{
alert(Answer.Incorrect);
return false;
}
}
vb
function CheckAnswer()
{
var firstInt = $get('firstNumber').innerText;
var secondInt = $get('secondNumber').innerText;
var userAnswer = $get('userAnswer');
if ((Number.parseLocale(firstInt) + Number.parseLocale(secondInt)) == userAnswer.value)
{
alert(Answer.Correct);
return true;
}
else
{
alert(Answer.Incorrect);
return false;
}
}
Permissions
Inheritance Hierarchy
Assembly: System.Web.Extensions (Module: System.Web.Extensions)