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

[Solved] Problem Getting Reference to Context Dictionary

1 Answer 95 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Rob
Top achievements
Rank 1
Rob asked on 07 Apr 2009, 08:22 PM
Can somebody explain to me why I can't get a reference to the Context Dictionary in JavaScript in the OnClientSelectedIndexChanged event?  I am able to reference and set key values in the OnClientItemsRequesting event with the exact same code.

Here's what I have:

<telerik:RadComboBox runat="server" ID="ddlColorCode" AutoPostBack="true" EnableLoadOnDemand="True" 
   OnClientSelectedIndexChanging="ddlSelIndexChanged"   
   OnClientSelectedIndexChanged="ddlColorCde_SelectedIndexChanged" 
   OnClientItemsRequesting="itmReq_ColorCde">  
   <WebServiceSettings Method="loadColorCde" Path="~/WebServices/srvc_ComboBox.asmx" /> 
   <CollapseAnimation Duration="200" Type="OutQuint" /> 
</telerik:RadComboBox> 
 
<script type="text/javascript">              
            function itmReq_ColorCde(s,e){  
                var context = e.get_context();  
                var cb = $find("<%= Me.ddlColorCode.ClientID %>");  
                context["ClrCde"] = cb.get_value();  
            }              
            function ddlSelIndexChanged(){  
                  window.parent.FrameClearNodes();  
            }      
            function ddlColorCde_SelectedIndexChanged(s,e){  
                var context = e.get_context();  
                var cb = $find("<%= Me.ddlColorCode.ClientID %>");  
                context["ClrCde"] = cb.get_value();  
            }               
</script> 

Thanks.

1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 08 Apr 2009, 09:29 AM
Hi Dudeman,

This is by design. The get_context property is only available during the OnClientItemsRequesting event. You can use a temporary variable and store the required data there during the OnClientSelectedIndexChanged. Then during OnClientItemsRequesting you can use that variable to populate the context:

<script type="text/javascript">
var data = null;

function selectedIndexChanged(sender, args)
{
    data = "some data";
}

function itemsRequesting(sender, args)
{
   args.get_context()["Custom"] = data;
}
</script>


Regards,
Albert
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Tags
ComboBox
Asked by
Rob
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or