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

[Solved] RadComboBox Javascript error 'addEventListner' is null or not an object2009.2.701.0

1 Answer 63 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Rajesh Meenrajan
Top achievements
Rank 1
Rajesh Meenrajan asked on 19 Aug 2009, 09:17 PM

Error:

'addEventListner' is null or not an object

 inside onload method:

 

 

panel.ID =

"Panel1";

 

 

this.Controls.Add(panel);

 

RadComboBox cbxName =

new RadComboBox();

 

 

 

cbxName.ID =

"cbxName";

 

cbxName.ItemsRequested +=

new RadComboBoxItemsRequestedEventHandler(cbxName_ItemsRequested);

 

cbxName.Skin = Skin;

 

 

 

panel.Controls.Add(cbxName);

 


RadAjaxManager

 

ajaxManager = RadAjaxManager.GetCurrent(this.Page);

 

 

if (ajaxManager == null)

 

{

ajaxManager =

new RadAjaxManager();

 

ajaxManager.ID =

"RadAjaxManager1";

 

Controls.Add(ajaxManager);

 

this.Page.Items.Add(typeof(RadAjaxManager), ajaxManager);

 

}

 

ajaxManager.AjaxSettings.AddAjaxSetting(cbxName, panel);

 

 

 


private

 

DataTable GetData(string text, string connString)

 

{

 

using (SqlConnection conn = new SqlConnection(connectionString))

 

{

conn.Open();

 

using (SqlCommand command = new SqlCommand("mystoredproc", conn))

 

{

command.CommandType =

CommandType.StoredProcedure;

 

command.Parameters.Add(

new SqlParameter("@paramName", text));

 

 

SqlDataAdapter adapter = new SqlDataAdapter(command);

 

 

DataTable data = new DataTable();

 

adapter.Fill(data);

 

return data;

 

}

}

}



 

protected

 

void cbxName_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)

 

{

 

try

 

 

 

 

{

 

int itemsPerRequest = 10;

 

 

if (e.Text.Length >= 3)

 

{

 

DataTable table = GetData(e.Text, connectionString);

 

 

int itemOffset = e.NumberOfItems;

 

 

int endOffset = Math.Min(itemOffset + itemsPerRequest, table.Rows.Count);

 

e.EndOfItems = endOffset == table.Rows.Count;

 

for (int i = itemOffset; i < endOffset; i++)

 

{

cbxName.Items.Add(

new RadComboBoxItem(table.Rows[i]["Name"].ToString(), table.Rows[i]["ID"].ToString()));

 

}

 

}

 

else

 

 

 

 

{

cbxName.Items.Clear();

}

}

 

catch (Exception ex)

 

{

 

throw ex;

 

}

}

1 Answer, 1 is accepted

Sort by
0
Helen
Telerik team
answered on 21 Aug 2009, 12:57 PM
Hello Rajesh,

Probably you will find helpful the following forum post:

http://www.telerik.com/community/forums/aspnet-ajax/editor/foolish-mistake.aspx


Regards,
Helen
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
ComboBox
Asked by
Rajesh Meenrajan
Top achievements
Rank 1
Answers by
Helen
Telerik team
Share this question
or