Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Why my ListBox Control in my Web Control is not Raising the SelectedIndexChanged Event ?

Reply
Thread Tools

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

 
 
msnews.microsoft.com
Guest
Posts: n/a
 
      04-28-2005
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



 
Reply With Quote
 
 
 
 
Karl Seguin
Guest
Posts: n/a
 
      04-28-2005
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" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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
>
>
>



 
Reply With Quote
 
 
 
 
msnews.microsoft.com
Guest
Posts: n/a
 
      04-28-2005
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:ekyY$(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>> 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
>>
>>
>>

>
>



 
Reply With Quote
 
=?Utf-8?B?YmNoYW5kbGV5?=
Guest
Posts: n/a
 
      04-28-2005
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
 
Reply With Quote
 
Roger Helliwell
Guest
Posts: n/a
 
      04-28-2005
On Wed, 27 Apr 2005 20:09:08 -0700 in
microsoft.public.dotnet.framework.aspnet, "msnews.microsoft.com"
<(E-Mail Removed)> 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

 
Reply With Quote
 
msnews.microsoft.com
Guest
Posts: n/a
 
      04-28-2005
Thanks a lot Brian it worked.


"bchandley" <Bchan3@yahoo-.-com> wrote in message
news:(E-Mail Removed)...
> 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



 
Reply With Quote
 
msnews.microsoft.com
Guest
Posts: n/a
 
      04-28-2005
Thanks a lot Roger it Worked.

"Roger Helliwell" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On Wed, 27 Apr 2005 20:09:08 -0700 in
> microsoft.public.dotnet.framework.aspnet, "msnews.microsoft.com"
> <(E-Mail Removed)> 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
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Composite Control ListBox SelectedIndexChanged event not firing studen771 ASP .Net Web Controls 0 03-27-2007 11:13 PM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM
Raising GridView's SelectedIndexChanged event in ASP .net 2.0 Jay ASP .Net Datagrid Control 1 06-08-2006 02:47 PM
Raising SelectedIndexChanged event in a gridview =?Utf-8?B?LU1U?= ASP .Net 2 06-06-2006 07:32 PM
Listbox Webcontrol SelectedIndexChanged Event not working Scott Lemen ASP .Net Web Controls 3 06-28-2005 09:21 PM



Advertisments