Registers a client script file that is embedded in an assembly with the ScriptManager control each time a postback occurs.
Syntax
CSharp
public static void RegisterClientScriptResource (
Page page,
Type type,
string resourceName
)
VisualBasic
Public Shared Sub RegisterClientScriptResource ( _
page As Page, _
type As Type, _
resourceName As String _
)
ManagedCPlusPlus
public:
static void RegisterClientScriptResource (
Page^ page,
Type^ type,
String^ resourceName
)
JSharp
public static void RegisterClientScriptResource (
Page page,
Type type,
String resourceName
)
Parameters
- page (Page)
The Page object that is registering the script.
- type (Type)
The type of the client script. This parameter is usually specified by using the typeof (C# Reference) operator (C#) or the GetType Operator operator (Visual Basic) to retrieve the type of the control that is registering the script.
- resourceName (String)
The control that is registering the script is not in the page's control tree.
Remarks
Registering a script file with this method causes the script to be rendered each time an asynchronous postback occurs. To register a script for a control inside an UpdatePanel control so that the script is registered only when the UpdatePanel control is updated, use the RegisterClientScriptResource(Control, Type, String) overload of this method.
If you are registering a script block that does not pertain to partial-page updates, and if you want to register a script block once during initial page rendering, use the RegisterClientScriptResource(Type, String) method of the ClientScriptManager class. You can get a reference to the ClientScriptManager object from the ClientScript property of the page.
Exceptions
| Exception | Condition |
|---|
| ArgumentNullException | The client resource type is null. - or - The page that is registering the script is null. |
Assembly: System.Web.Extensions (Module: System.Web.Extensions)