473,325 Members | 2,828 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Why my ListBox Control in my Web Control is not Raising the SelectedIndexChanged Event ?

Hi All,

I am creating a control with ASP "ListBox" control.

Also I have added necessary code to handle the ListBox.SelectedItemChanged
Event.

But surprisingly the control is not comng to this code at all.

Why my ListBox Control in my Web Control is not Raising the
SelectedIndexChanged Event ?

Any suggestions please?

Thanks
Anand Ganesh

Nov 19 '05 #1
6 1423
did you set the AutoPostBack property to true?

<asp:listbox ... AutoPostBack="True" />

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"msnews.microsoft.com" <ag*****@nobel-systems.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi All,

I am creating a control with ASP "ListBox" control.

Also I have added necessary code to handle the ListBox.SelectedItemChanged
Event.

But surprisingly the control is not comng to this code at all.

Why my ListBox Control in my Web Control is not Raising the
SelectedIndexChanged Event ?

Any suggestions please?

Thanks
Anand Ganesh

Nov 19 '05 #2
Yes I did. Here is the code.

protected override void CreateChildControls()

{

foreach(string st in this.GlobalArrayList)

{

TheListBox.Items.Add(st) ;

}

TheListBox.Attributes.Add("AutoPostBack","True") ;

TheListBox.Attributes.Add("id","ListBoxCheck") ;

TheListBox.Attributes.Add("runat","server") ;

TheListBox.Attributes.Add("OnSelectedIndexChanged" ,"TheListBox_SelectedIndexChanged")
;

this.Controls.Add(TheListBox) ;

Button TheButton = new Button() ;

TheButton.Click +=new EventHandler(TheButton_Click);

this.Controls.Add(TheButton) ;

//base.CreateChildControls ();

}
But still the TheListBox_SelectedIndexChanged function is not being called.

I am using the CreateChildControls() function to create my controls and I am
not overiding and using the render function.

Will this cause an issue?

Thank
Anand

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:ek**************@TK2MSFTNGP14.phx.gbl...
did you set the AutoPostBack property to true?

<asp:listbox ... AutoPostBack="True" />

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"msnews.microsoft.com" <ag*****@nobel-systems.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi All,

I am creating a control with ASP "ListBox" control.

Also I have added necessary code to handle the
ListBox.SelectedItemChanged Event.

But surprisingly the control is not comng to this code at all.

Why my ListBox Control in my Web Control is not Raising the
SelectedIndexChanged Event ?

Any suggestions please?

Thanks
Anand Ganesh


Nov 19 '05 #3
TheListBox.Attributes.Add("AutoPostBack","true") ;
Will add an "AutoPostBack" Attrubute to the rendered oupput of your control,
but will not set this property of the control.

try:

TheListBox.AutoPostBack=true

TheListBox.Attributes.Add("id","ListBoxCheck") ;
TheListBox.OnSelectedIndexChanged +=new
EventHandlerTheListBox_SelectedIndexChanged);
Hope this helps.
Brian
Nov 19 '05 #4
On Wed, 27 Apr 2005 20:09:08 -0700 in
microsoft.public.dotnet.framework.aspnet, "msnews.microsoft.com"
<ag*****@nobel-systems.com> wrote:

TheListBox.Attributes.Add("AutoPostBack","True" ) ;

TheListBox.Attributes.Add("id","ListBoxCheck") ;

TheListBox.Attributes.Add("runat","server") ;

TheListBox.Attributes.Add("OnSelectedIndexChanged ","TheListBox_SelectedIndexChanged")
;


Hi,

The 'attributes' collection you are adding to, is for client-side
attributes only. Instead, use the appropriate property of the ListBox
control like this:

TheListBox.AutoPostBack = true;
TheListBox.ID = "ListBoxCheck";
TheListBox.SelectedIndexChanged += new
EventHandler(TheListBox_SelectedIndexChanged);

Roger

Nov 19 '05 #5
Thanks a lot Roger it Worked.

"Roger Helliwell" <rh********@telus.net> wrote in message
news:ea********************************@4ax.com...
On Wed, 27 Apr 2005 20:09:08 -0700 in
microsoft.public.dotnet.framework.aspnet, "msnews.microsoft.com"
<ag*****@nobel-systems.com> wrote:

TheListBox.Attributes.Add("AutoPostBack","True ") ;

TheListBox.Attributes.Add("id","ListBoxCheck") ;

TheListBox.Attributes.Add("runat","server") ;

TheListBox.Attributes.Add("OnSelectedIndexChange d","TheListBox_SelectedIndexChanged")
;


Hi,

The 'attributes' collection you are adding to, is for client-side
attributes only. Instead, use the appropriate property of the ListBox
control like this:

TheListBox.AutoPostBack = true;
TheListBox.ID = "ListBoxCheck";
TheListBox.SelectedIndexChanged += new
EventHandler(TheListBox_SelectedIndexChanged);

Roger

Nov 19 '05 #6
Thanks a lot Brian it worked.
"bchandley" <Bchan3@yahoo-.-com> wrote in message
news:60**********************************@microsof t.com...
TheListBox.Attributes.Add("AutoPostBack","true") ;
Will add an "AutoPostBack" Attrubute to the rendered oupput of your
control,
but will not set this property of the control.

try:

TheListBox.AutoPostBack=true

TheListBox.Attributes.Add("id","ListBoxCheck") ;
TheListBox.OnSelectedIndexChanged +=new
EventHandlerTheListBox_SelectedIndexChanged);
Hope this helps.
Brian

Nov 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Edward | last post by:
I am having a terrible time getting anything useful out of a listbox on my web form. I am populating it with the results from Postcode lookup software, and it is showing the results fine. What...
6
by: Steve | last post by:
Hi, I open up a webform (vb.net) and populate a listbox control on the Page load event. If I click on (select) and item from the listbox I want to write the value of the selected item to a...
18
by: Dave Sauny | last post by:
Ok, its a friday, I'm at work and I cant get this to work: I have 3 listboxes on one tab control page. when i select an item in listbox1 i want whatever is selected on the other 2 listboxes...
0
by: John Dann | last post by:
I had a listbox that allows reordering of listed items using the mouse to drag and drop. In the DragDrop event handler, the key instructions are: MyListBox..Items.RemoveAt(PreMoveIndex)...
3
by: Alec MacLean | last post by:
Hi everyone, I have a ComboBox that when changed, calls a method to change the content of a ListBox. I'm also using the Listbox's SelectedIndexChanged event to change other control values on...
4
by: Selva Chinnasamy | last post by:
I like to implement auto scrolling to the best match in the listbox as I type. Your response is highly appreciated. Selva
2
by: teo | last post by:
I have a Listbox, if I set EnableViewStarte = False the AutopostaBack fired by SelectedIndexChanged doesn't work. The 'SelectedIndexChanged' event should call
9
by: zdrakec | last post by:
Hello all: Clearly, I'm not getting it! Here is the scenario: On a web page, I have two list boxen and a text box. The first listbox is populated at page load time (if it is not a postback)....
6
by: Mike | last post by:
Is there a way to get a ListView control to fire its SelectedIndexChanged event like the ListBox control? When the user selects multiple items at once, the ListView fires the event as each item...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.