Domanda

This has been bugging me for a good hour. I'm starting out with Telerik Controls, and I probably missed out a few steps, but the code below is trying to find out the selectedItem via client side scripting:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TestRadListBox.aspx.cs" Inherits="TestRadListBox" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript" src="javascript/jquery-1.7.1.min.js"></script>
    <script type="text/javascript">
        function clickMe() {
            var rlb = $('#<%# rlbTemp.ClientID %>');
            alert('rlb = ' + rlb + '; rlb.get_selectedItem = ' + rlb.get_selectedItem);

        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
        <div>
            <telerik:RadListBox runat="server" ID="rlbTemp"></telerik:RadListBox>

            <input type="button" value="Click Me" onclick="clickMe();"/>
        </div>
    </form>
</body>
</html>

The problem I have is the function get_selectedItem is nowhere to be found. Basically, how can I have a reference to it? I tried looking if there's a reference I missed, but it seems the radscriptmanager should be sufficient, yet, when I looked at what it's exposing, there is no get_selectedItem in it.

Thanks in advance.

È stato utile?

Soluzione

Try replacing your JSCode with the following :

function clickMe() {

    var rlb = $find('<%= rlbTemp.ClientID %>');
    alert('rlb = ' + rlb + '; rlb.get_selectedItem = ' + rlb.get_selectedItem);

}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top