Documentation for: ASP.NET Ajax Version 1.0

This documentation is for a previous version. For the current released version, see the ASP.NET Ajax documentation on MSDN.








Error.parameterCount Function

Creates an Error Object object that represents the Sys.ParameterCountException exception.


var err = Error.parameterCount(message);



(Optional) An error message string. The value can be null. If message is null, a default message is used.

Return Value

An Error object.


The parameterCount function lets you communicate that an exception has occurred when an invalid number of arguments have been passed to a function. The message argument enables you to specify additional error information.


The following example shows how to create, throw, and catch a Sys.ParameterCountException error by using the parameterCount function.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="" >
<head id="Head1" runat="server">
    <form id="form1" runat="server">
       <asp:ScriptManager runat="server" ID="ScriptManager1">

       <script type="text/javascript">

            function throwAnError(a, b) 
                    if (arguments.length !== arguments.callee.length)
                        // Throw a standard exception.
                        var err = Error.parameterCount("Invalid number of parameters attempted."); 
                        throw err;
                    alert("No error occured.");

        // Result: A Thrown Sys.ParameterCountException with the following message:
        // Error: Sys.ParameterCountException: Invalid number of parameters attempted.