Pass RadListBox selected value as route value in LoadContentFrom on Telerik Window

Thread is closed for posting
3 posts, 0 answers
  1. Donna Stewart
    Donna Stewart avatar
    127 posts
    Member since:
    Apr 2009

    Posted 28 Dec 2010 Link to this post

    I have a RadListBox with checkboxes.  I would like the user to be able to select an item in the listbox and click on an Edit link to open up a popup in which the user can edit the information based on the selected item.  So I need to pass the selected value as an id (key) in the LoadContentFrom on my Telerik Window.  I am not sure as to how to do this.  I tried creating a hidden field and setting it using the OnClientItemChecked, but I am having difficulty actually getting the selected item and its value.  The listbox is not being found - please see the code below.

        <script language="javascript" type="text/javascript">
      
            function setSelectedUser() {
                var listBox = $find('<%= UsersLB.ClientID %>_ClientState');
                var selectedItem = listBox.get_selectedItem();
                document.getElementById("selectedUser").value = selectedItem.get_value());
            }
        </script>
        <%  UsersLB.DataSource = Model.userList
            UsersLB.DataValueField = "Value"
            UsersLB.DataTextField = "Text"
            UsersLB.DataBind()
              
            UserGroupsLB.DataSource = Model.userGroupList
            UserGroupsLB.DataValueField = "Value"
            UserGroupsLB.DataTextField = "Text"
            UserGroupsLB.DataBind()
        %>
        <div id="mainright">
            <asp:HiddenField ID="selectedUser" runat="server"/>
            <div>
                <telerik:RadListBox ID="UsersLB" runat="server" CheckBoxes="true" Height="300px" OnClientItemChecked="setSelectedUser()">
                </telerik:RadListBox>
                <a href="#" id="newUser">New</a>       <a href="#" id="editUser">Edit</a>
                <%  Html.Telerik().Window().Name("CreateWindow") _
                    .LoadContentFrom("Create", "User") _
                    .Buttons(Function(buttons) buttons.Refresh().Maximize().Close()) _
                    .Draggable(True) _
                    .Height(450) _
                    .Width(500) _
                    .Resizable() _
                    .Title("Create New GMC Web User") _
                    .HtmlAttributes(New With {.class = "windows7"}) _
                    .Visible(False) _
                    .Render()
                 %>
                <%  Html.Telerik().Window().Name("EditWindow") _
                    .LoadContentFrom("Edit", "User") _
                    .Buttons(Function(buttons) buttons.Refresh().Maximize().Close()) _
                    .Draggable(True) _
                    .Height(450) _
                    .Width(500) _
                    .Resizable() _
                    .Title("Edit GMC Web User") _
                    .HtmlAttributes(New With {.class = "windows7"}) _
                    .Visible(False) _
                    .Render()
                 %>
            </div>
            <div>
                <telerik:RadListBox ID="UserGroupsLB" runat="server" CheckBoxes="true" Height="300px">
                </telerik:RadListBox>
            </div>
      
        </div>
        <%  Html.Telerik().ScriptRegistrar().OnDocumentReady("$('#newUser').bind('click', function openWindow(e){ $('#CreateWindow').data('tWindow').center().open().refresh();})")
                .OnDocumentReady("$('#editUser').bind('click', function openWindow(e){$('#EditWindow').data('tWindow').center().open()>refresh();})")
    %>


     Can you please point me in the right direction as to how to do what I need?

    Thank you very much,
    Donna
  2. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 04 Jan 2011 Link to this post

    Hi Donna,

    You should reference the listbox using only its ClientID like this:

    var listBox = $find('<%= UsersLB.ClientID %>');


    Best wishes,
    Yana
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Donna Stewart
    Donna Stewart avatar
    127 posts
    Member since:
    Apr 2009

    Posted 05 Jan 2011 Link to this post

    Hi and thank you for your help.  I had actually tried your suggestion before, but it didn't work either.  I am really sorry, I failed to mention that this is an MVC application. I have changed the app to use the Telerik MVC TreeView instead of the RadListBox, but thank you again for your help!

    Donna
Back to Top