ScriptableMemberAttribute.ScriptAlias Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets or sets the name of a property, method, or event that is exposed to JavaScript code. By default, the script alias is the same as the name of the managed property, method, or event.

Namespace:  System.Windows.Browser
Assembly:  System.Windows.Browser (in System.Windows.Browser.dll)

Syntax

'Declaration
Public Property ScriptAlias As String
public string ScriptAlias { get; set; }

Property Value

Type: System.String
The name of a property, method, or event.

Exceptions

Exception Condition
ArgumentException

The alias is set to an empty string.

ArgumentNullException

The alias is set to nulla null reference (Nothing in Visual Basic).

Remarks

You can use this property to provide an alias for a property, method, or event (PME). For example, if multiple method overloads exist on a scriptable object, you can differentiate them by providing script aliases for each overload. You can also use the ScriptAlias property to create a friendly name for a PME that has a long or confusing name.

Examples

The following example sets a ScriptAlias of "MVLN" for the method named "Method_With_a_Very_Long_Name".

public class SMT_ScriptableManagedType
    {
    [ScriptableMember]                       // No ScriptAlias is set
     public string GetString()
        { return "abcdefg"; }

     public string GetString()
        { return "abcdefg"; }

    [ScriptableMember(ScriptAlias = "MVLN")]  // ScriptAlias is set
     public string Method_With_a_Very_Long_Name
        {
        return "abcdefg";
        }
}

Version Information

Silverlight

Supported in: 5, 4, 3

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.