This is a migrated thread and some comments may be shown as answers.

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

2 Answers 99 Views
UI for ASP.NET AJAX in ASP.NET MVC
This is a migrated thread and some comments may be shown as answers.
Donna Stewart
Top achievements
Rank 1
Donna Stewart asked on 29 Dec 2010, 04:44 AM
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 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 04 Jan 2011, 09:20 AM
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.
0
Donna Stewart
Top achievements
Rank 1
answered on 05 Jan 2011, 10:13 PM
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
Tags
UI for ASP.NET AJAX in ASP.NET MVC
Asked by
Donna Stewart
Top achievements
Rank 1
Answers by
Yana
Telerik team
Donna Stewart
Top achievements
Rank 1
Share this question
or