Get DataTextField on Client

2 posts, 1 answers
  1. Dave
    Dave avatar
    9 posts
    Member since:
    Feb 2011

    Posted 08 Sep Link to this post

    Hi,

    On the client, is there a way to get the value of the DataTextField used for binding?   The RadComboBox client object has a property _dataTextField, but this is always empty.

    Thanks,

    Dave

     

  2. Answer
    Vessy
    Admin
    Vessy avatar
    2301 posts

    Posted 11 Sep Link to this post

    Hi Dave,

    The _dataTextField property returns a value only if the ComboBox is bound on the client-side. If you are binding it on the server-you can keep the value of the DataTextField into a hidden field on the page, accessing its value directly when needed.

            <telerik:RadComboBox ID="RadCombobox1" runat="server"></telerik:RadComboBox>
            <asp:HiddenField ID="HiddenField1" runat="server" />
    

            RadCombobox1.DataTextField = "TextFieldName";
            HiddenField1.Value = "TextFieldName";
            ...

    And when you need this value on the client-side:

                function accessTextField() {
                    var dataTextFiel = $get("HiddenField1").value;
                }

    Regards,
    Vessy
    Progress Telerik

    Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Back to Top