Jul 24, 2010, 12:59 PM
Problem with Ajaxevents on dynamically created ComboBox
Hello all,
I have a desktop window, which controls dinamically created in code behind, based on the properties of an object being edited on the form.
For some Comboboxes on that form i need to have an ajax-event every time the selection is changed.
When I try this in markup with the code below, it works just fine:
I have a desktop window, which controls dinamically created in code behind, based on the properties of an object being edited on the form.
For some Comboboxes on that form i need to have an ajax-event every time the selection is changed.
When I try this in markup with the code below, it works just fine:
<ext:ComboBox ID="cbPatientList" runat="server" Enabled="false" FieldLabel="Patients"
Width="200">
<AjaxEvents>
<Select OnEvent="cbPatientsListSelect">
</Select>
</AjaxEvents>
</ext:ComboBox>
But when i use any of the events below in code behind, nothing happens when element is selected:protected void Page_Load(object sender, EventArgs e)
{
if (!Ext.IsAjaxRequest)
{
...
var field = ClientUtils.GetFieldByPropertyDescriptor(prop, out valueFieldName);
if (field != null && field is ComboBox)
{
var comboBox = field as ComboBox;
comboBox.AjaxEvents.Select.Event += new ComponentAjaxEvent.AjaxEventHandler(Select_Event);
comboBox.ItemSelected += new EventHandler(ComboItemSelected);
comboBox.ValueChanged += new EventHandler(ComboValueChanged);
comboBox.Listeners.Change.Handler = "Coolite.AjaxMethods.newCompany();";
}
var anchor = new Anchor();
anchor.Items.Add(field);
FormLayout33.Anchors.Add(anchor);
...
}
void ComboValueChanged(object sender, EventArgs e)
{
throw new NotImplementedException();
}
void ComboItemSelected(object sender, EventArgs e)
{
throw new NotImplementedException();
}
public void Select_Event(object sender, AjaxEventArgs e)
{
throw new NotImplementedException();
}
[AjaxMethod]
public void newCompany()
{
}
What am i doing wrong?