Hi,
I'm trying to change a ComboBoxItem's text from client side when then text of a radTextBox in another radPanel was changed. It seems to work (partially) but as soon as the page refreshes, I lose all changes and the radComboBox is repopulated with the default values, even though the new values are still present in the textbox. Here is the client side code for the change:
Javascript:
and here's the code that is executed when the panel is being populated:
VB:
Any help would be greatly appreciated
Thank you
Sam
I'm trying to change a ComboBoxItem's text from client side when then text of a radTextBox in another radPanel was changed. It seems to work (partially) but as soon as the page refreshes, I lose all changes and the radComboBox is repopulated with the default values, even though the new values are still present in the textbox. Here is the client side code for the change:
Javascript:
function
RefreshPreneursPrenom(sender, args) {
var
cell = sender.get_element().parentNode.parentNode;
var
index = cell.parentNode.rowIndex - 1;
var
prenom = (sender.get_element().value);
var
combo = $find(
"<%= rcbPreneur.ClientID %>"
);
if
(combo !=
null
) {
var
items = combo.get_items();
var
comboItem =
new
Telerik.Web.UI.RadComboBoxItem();
var
comboItem = items.getItem(index);
var
nomComplet = comboItem.get_text();
var
nomComplet2 = nomComplet.split(
" "
);
var
nomFamille = nomComplet2[1];
var
nomComplet3 = (prenom.concat(
" "
, nomFamille));
comboItem.set_text(nomComplet3);
combo.trackChanges();
combo.commitChanges();
comboItem.Select;
document.getElementById(
"<%= rapPreneur.ClientID %>"
).style.display =
'block'
;
}
}
and here's the code that is executed when the panel is being populated:
VB:
Dim
i
As
Int32
Dim
listeAssures
As
New
OCollection(Of Assure)
For
i = 0
To
NbreVoyageurs - 1
Dim
assure
As
New
Assure
Dim
rgItem
As
GridDataItem =
DirectCast
(rgDetailsVoyageurs.MasterTableView.Items(i), GridDataItem)
Dim
item
As
New
Telerik.Web.UI.RadComboBoxItem
Dim
id
As
New
HiddenField
id =
DirectCast
(rgItem(
"Prenom"
).FindControl(
"IDVoyageur"
+ (i + 1).ToString), HiddenField)
assure.IDClient =
CLng
(id.Value)
Dim
prenom
As
New
Telerik.Web.UI.RadTextBox
prenom =
DirectCast
(rgItem(
"Prenom"
).FindControl(
"PrenomVoyageur"
+ (i + 1).ToString), Telerik.Web.UI.RadTextBox)
assure.Prenom = prenom.Text
Dim
nom
As
New
Telerik.Web.UI.RadTextBox
nom =
DirectCast
(rgItem(
"Nom"
).FindControl(
"NomVoyageur"
+ (i + 1).ToString), Telerik.Web.UI.RadTextBox)
assure.Nom = nom.Text
'construction de la date de naissance
Dim
txtJour
As
New
Telerik.Web.UI.RadNumericTextBox
txtJour =
DirectCast
(rgItem(
"Date de naissance"
).FindControl(
"DateNaissanceJourVoy"
+ (i + 1).ToString), Telerik.Web.UI.RadNumericTextBox)
Dim
jourNaissance
As
Integer
=
CInt
(txtJour.Value)
Dim
txtMois
As
New
Telerik.Web.UI.RadComboBox
txtMois =
DirectCast
(rgItem(
"Date de naissance"
).FindControl(
"DateNaissanceMoisVoy"
+ (i + 1).ToString), Telerik.Web.UI.RadComboBox)
Dim
moisNaissance
As
Integer
=
CInt
(txtMois.SelectedValue.ToString)
Dim
txtAnnee
As
New
Telerik.Web.UI.RadNumericTextBox
txtAnnee =
DirectCast
(rgItem(
"Date de naissance"
).FindControl(
"DateNaissanceAnVoy"
+ (i + 1).ToString), Telerik.Web.UI.RadNumericTextBox)
Dim
anneeNaissance
As
Integer
=
CInt
(txtAnnee.Value)
assure.DateNaissance =
New
Date
(anneeNaissance, moisNaissance, jourNaissance)
Dim
checkACharge
As
New
CheckBox
checkACharge =
DirectCast
(rgItem(
"A Charge"
).FindControl(
"AChargeVoy"
+ (i + 1).ToString()), CheckBox)
assure.IsPersonneACharge = checkACharge.Checked
Dim
age
As
Integer
= Today.Year - assure.DateNaissance.Year
If
assure.DateNaissance.Month > Today.Month
OrElse
_
(assure.DateNaissance.Month = Today.Month
AndAlso
assure.DateNaissance.Day > Today.Day
AndAlso
_
assure.DateNaissance.Day <> Today.Day)
Then
'The current year is not yet complete.
age -= 1
End
If
If
(age > 15)
Then
item.Text = assure.Prenom +
" "
+ assure.Nom
item.Value = assure.IDClient.ToString
rcbPreneur.Items.Add(item)
End
If
Next
Components.AddRange(listeAssures)
rcbPreneur.DataBind()
rapPreneur.Visible =
True
Any help would be greatly appreciated
Thank you
Sam