Skip to main content
A newer version of this page is available. .

ASPxClientControlCollection.GetByName(name) Method

Returns a DevExpress client control object identified by its unique hierarchically-qualified identifier (either ClientInstanceName or ClientID property value).

Declaration

GetByName(
    name: string
): any

Parameters

Name Type Description
name string

A string value that is the hierarchically-qualified identifier of the required DevExpress control.

Returns

Type Description
any

An object that is the client control object found.

Remarks

The GetByName method provides you with programmatic access to a DevExpress control’s client object specified by the control’s hierarchically-qualified identifier (namely the value of its ClientInstanceName or ClientID property), that uniquely identifies the object on the client side.

This method initially searches an object specified by the name parameter within the DevExpress collection of client objects, and then (if it is not found) - within the window’s entire collection of client objects. If found, an object instance is returned.

In some cases, using the GetByName method might be an alternative to using a control’s ClientInstanceName property. For instance, when working with templates, there might be situations when the client identifier of a web control’s top HTML element is composed dynamically within iterative loops on the client. Within each loop, you can use the static ASPxClientControl.GetControlCollection method and the GetByName method to evaluate the HTML element and access its corresponding client object (ASPxClient…) providing the entire required client API.

Example

This example demonstrates how the ASPxClientControl.GetControlCollection and ASPxClientControlCollection.GetByName methods can be used on the client, to access an ASPxTextBox editor’s client instance. The editor is contained within an ASPxPanel control, which is placed within the first tab page of an ASPxPageControl.

<form id="form1" runat="server">

    <script type="text/javascript" >
        var editorClientId = "<%=ASPxTextBox1.ClientID%>";
    </script>

    <dx:ASPxPageControl ID="ASPxPageControl1" runat="server" ActiveTabIndex="0">
        <TabPages>
            <dx:TabPage>
                <ContentCollection>
                    <dx:ContentControl runat="server">

                        <dx:ASPxPanel ID="ASPxPanel1" runat="server" Width="200px">
                            <PanelCollection>
                                <dx:PanelContent runat="server">

                                    <dx:ASPxTextBox ID="ASPxTextBox1" runat="server" ClientInstanceName="myTextBox" Text="Some text" Width="170px">
                                    </dx:ASPxTextBox>

                                </dx:PanelContent>
                            </PanelCollection>
                        </dx:ASPxPanel>

                    </dx:ContentControl>
                </ContentCollection>
            </dx:TabPage>
            <dx:TabPage>
                <ContentCollection>
                    <dx:ContentControl ID="ContentControl1" runat="server">
                    </dx:ContentControl>
                </ContentCollection>
            </dx:TabPage>
        </TabPages>
    </dx:ASPxPageControl>

    <dx:ASPxButton ID="ASPxButton1" runat="server" AutoPostBack="False" Text="Get text">
        <ClientSideEvents Click="function(s, e) {
            var editor = ASPxClientControl.GetControlCollection().GetByName(editorClientId);
            alert(editor.GetText());
        }" />
    </dx:ASPxButton>
</form>
See Also