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

Incorrect Values at Server Side

0 Answers 71 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
chrispo
Top achievements
Rank 1
chrispo asked on 16 Apr 2010, 05:36 AM
############## Closed this item, after figuring it out.  ##############################



I have a page with three RadComboBoxes and a submit button.  The submit is inside a RadAjaxPanel, with a textbox for the results of the click.

The functionality I want is to Textclick the button, and the value of the selected items in the combo boxes is displayed in the textbox.

It seems whatever item I select in combo 1 and 3, I get null as the selected item, even though the Text property of the combobox correctly identifies the item selected. Combo 2 works correctly.

I used Firefox to see what was being posted to the server. 
For combo 1
{"logEntries":[],"value":"zr4","text":"Medium Density Residential Area","enabled":true}
For combo 3

{"logEntries":[],"value":"5","text":"Code Purpose","enabled":true}

For combo 2 
{"logEntries":[{"Type":1,"Index":0,"Data":{"text":"Please Select","value":"0","selected":true}},{"Type":1,"Index":1,"Data":{"text":"Centre Activities (except Amusement Arcade, Child ...","value":"uc1843"}},{"Type":1,"Index":2,"Data":{"text":"Centre Activities (except Amusement Arcade, Child ...","value":"uc1890"}},{"Type":1,"Index":3,"Data":{"text":"Centre Activities where not involving building wor...","value":"uc1919"}},{"Type":1,"Index":4,"Data":{"text":"Centre Activities (except Display and Sales Activi...","value":"uc1932"}},{"Type":1,"Index":5,"Data":{"text":"Building work involving alterations to the facade ...","value":"wb1951"}},{"Type":1,"Index":6,"Data":{"text":"Centre Activities (except Display and Sales Activi...","value":"uc1996","selected":true}},{"Type":1,"Index":7,"Data":{"text":"Centre Activities whether or not involving buildin...","value":"uc2022"}},{"Type":1,"Index":8,"Data":{"text":"Demolition or removal of a Multi–unit Dwelling (wh...","value":"wd2046"}}],"value":"wd2046","text":"Demolition or removal of a Multi–unit Dwelling (wh...","enabled":true}

How do I access the value variables for combos 1, 2 and 3 - because the SelectedValue, SelectedItem, SelectedText properties arent working for me in this case?

Also, why is it that the Firefox post seems to identify the first item as selected whatever item I choose, but in fact its the only one that returns the correct item when I use SelectedValue, SelectedItem, SelectedText.  The other two are atleast sending the correct items to the server!

Very confused.

Ive posted the page code and code behind below.  Really appreciate your advice.

<%

@ Page Language="C#" MasterPageFile="~/Masterpages/MasterPage.master" AutoEventWireup="true" CodeFile="Slice2.aspx.cs" Inherits="Slice2" Title="Untitled Page" %>

 

<%

 

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

 

 

<

 

asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">

 

 

 

<title>Slice: thePlanBox</title>

 

 

 

<telerik:RadScriptBlock ID="RadScriptBlock2" runat="server">

 

 

 

<script type="text/javascript">

 

 

 

var pgs = new Array('Find','Review','Navigate','Read');

 

DoSetup(pgs);

 

 

</script>

 

 

 

</telerik:RadScriptBlock>

 

 

 

 

<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">

 

 

 

<script type="text/javascript">

 

 

 

function OnRC1ClientSelectedIndexChanged(sender, args)

 

{

 

 

var value = args.get_item().get_value();

 

 

 

if (value != "0") {

 

 

 

var panel = $find("<%=RadXmlHttpPanel1.ClientID %>");

 

panel.set_value(value);

}

 

else {

 

 

 

var combo = $find('<%=rc2.ClientID %>');

 

combo.clearItems();

combo.clearSelection();

}

}

 

 

function OnClientResponseEnding(panel, args) {

 

 

 

var count = args.get_content().length;

 

 

 

var combo = $find('<%=rc2.ClientID %>');

 

combo.clearItems();

combo.clearSelection();

 

 

var selectItem = new Telerik.Web.UI.RadComboBoxItem();

 

selectItem.set_text(

 

"Please Select");

 

selectItem.set_value(

 

"0");

 

combo.trackChanges();

combo.get_items().add(selectItem);

selectItem.select();

combo.commitChanges();

 

 

for (var i = 0; i < count; i++) {

 

 

 

var item = args.get_content()[i];

 

 

 

var comboItem = new Telerik.Web.UI.RadComboBoxItem();

 

comboItem.set_text(item.Name);

comboItem.set_value(item.ID);

combo.trackChanges();

combo.get_items().add(comboItem);

combo.commitChanges();

}

args.set_cancel(

 

true);

 

}

 

 

 

</script>

 

 

 

</telerik:RadScriptBlock>

 

 

 

 

</

 

asp:Content>

 

<

 

 

asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

 

<

 

 

div id="tpb_default_pagecontrols">

 

<

 

 

telerik:RadXmlHttpPanel ID="RadXmlHttpPanel1" runat="server"

 

 

 

WebMethodPath="WebService.asmx"

 

 

 

WebMethodName="GetActivitiesForPlace"

 

 

 

EnableClientScriptEvaluation="true"

 

 

 

OnClientResponseEnding="OnClientResponseEnding" LoadingPanelID="LoadingPanel1">

 

 

 

</telerik:RadXmlHttpPanel>

 

 

 

 

 

 

<div id="tpb_clientdocumentcombos">

 

 

 

 

<div>

 

 

 

<div class="tpb_controllabel">Places</div>

 

 

 

<div class="tpb_shadowcombo"><telerik:RadComboBox ID="rc1" runat="server"

 

 

 

OnClientSelectedIndexChanged="OnRC1ClientSelectedIndexChanged" Width="600"></telerik:RadComboBox></div>

 

 

 

<div class="tpb_dropshadow"><asp:Image ID="DDImage1" runat="server" ImageUrl="Images/DD_Shadow.png" /></div>

 

 

 

</div>

 

 

 

 

<div>

 

 

 

<div class="tpb_controllabel">Activities</div>

 

 

 

<div class="tpb_shadowcombo"><telerik:RadComboBox ID="rc2" Runat="server" Width="600"></telerik:RadComboBox></div>

 

 

 

<div class="tpb_dropshadow"><asp:Image ID="Image1" runat="server" ImageUrl="Images/DD_Shadow.png" /></div>

 

 

 

</div>

 

 

 

 

<div>

 

 

 

<div class="tpb_controllabel">Choose criteria types</div>

 

 

 

<div class="tpb_shadowcombo"><telerik:RadComboBox ID="rc3" Runat="server" Width="600"></telerik:RadComboBox></div>

 

 

 

<div class="tpb_dropshadow"><asp:Image ID="Image2" runat="server" ImageUrl="Images/DD_Shadow.png" /></div>

 

 

 

</div>

 

 

 

<div class="tpb_loadingmsg">

 

 

 

<telerik:RadAjaxLoadingPanel id="LoadingPanel1" Runat="server">

 

 

 

<asp:Image id="Image3" runat="server" ImageUrl="Images/ajax-loader.gif" >

 

 

 

</asp:Image>

 

 

 

</telerik:RadAjaxLoadingPanel>

 

 

 

</div>

 

 

 

</div>

 

 

 

 

 

<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" Height="200px"

 

 

 

Width="600px" LoadingPanelID="LoadingPanel1">

 

 

 

 

<asp:Button ID="Button1" runat="server" Text="Show Me" onclick="Button1_Click" />

 

 

 

<asp:Literal ID="xml1" runat="server" Mode="PassThrough" EnableViewState="false"></asp:Literal>

 

 

 

 

</telerik:RadAjaxPanel>

 

 

 

</div>

 

 

 

</

 

 

asp:Content>

 

 









No answers yet. Maybe you can help?

Tags
ComboBox
Asked by
chrispo
Top achievements
Rank 1
Share this question
or