Back to Devexpress

ASPxRichEdit.ClientInstanceName Property

aspnet-devexpress-dot-web-dot-aspxrichedit-dot-aspxrichedit-3767caca.md

latest3.8 KB
Original Source

ASPxRichEdit.ClientInstanceName Property

Specifies the ASPxRichEdit‘s client programmatic identifier.

Namespace : DevExpress.Web.ASPxRichEdit

Assembly : DevExpress.Web.ASPxRichEdit.v25.2.dll

NuGet Package : DevExpress.Web.Office

Declaration

csharp
[DefaultValue("")]
public string ClientInstanceName { get; set; }
vb
<DefaultValue("")>
Public Property ClientInstanceName As String

Property Value

TypeDefaultDescription
StringString.Empty

The control’s client identifier.

|

Remarks

Use the ClientInstanceName property to specify a unique client-side identifier for the ASPxRichEdit control. Use this identifier on the client side to access the ASPxClientRichEdit object programmatically.

Example

aspx
<script type="text/javascript">
    function getAllText() {
        return RichEdit.document.activeSubDocument.text;
    }
    function getSelectedText() {
        var firstSelectedInterval = RichEdit.selection.intervals[0];
        var selectedText = RichEdit.document.activeSubDocument.text.substr(firstSelectedInterval.start, firstSelectedInterval.length);
        return selectedText;
    }
</script>
<dx:ASPxButton runat="server" ID="Button1" Text="Get All Text" AutoPostBack="false">
    <ClientSideEvents Click="function(s, e) { alert(getAllText()); }" />
</dx:ASPxButton>
<dx:ASPxButton runat="server" ID="Button2" Text="Get Selected Text" AutoPostBack="false">
    <ClientSideEvents Click="function(s, e) { alert(getSelectedText()); }" />
</dx:ASPxButton>

<dx:ASPxRichEdit ID="RichEdit" runat="server" ClientInstanceName="RichEdit">
</dx:ASPxRichEdit>

The ClientInstanceName property is important when a control is contained within a naming container, for instance, within an ASPxPageControl‘s page or an ASPxPopupControl‘s window.

If the ClientInstanceName property is not specified for a control, the control’s client identifier is generated automatically and equals the value of the control’s ID property. Note that in this case, client-side programmatic access to the control is not allowed when the control is contained within a naming container.

Special Characters in Client Instance Name

If the ClientInstanceName property contains special characters, for instance, the dot (.), you cannot access a client object by this name. Call the GetByName(name) method to retrieve the client-side object instead.

aspx
<dx:ASPxTextBox ... ClientInstanceName="SomeType.SomeProp" />
js
var txt = ASPxClientControl.GetControlCollection().GetByName("SomeType.SomeProp");  
txt.SetText("Some Text");

See Also

Online Demo: Client Command API

ASPxRichEdit Class

ASPxRichEdit Members

DevExpress.Web.ASPxRichEdit Namespace