|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
DropDownList selectedIndexChanged event not firingMy dropdown list with autopostback set to true is returning to the
application but my even handler for selectedIndexChanged isn't firing. in InitializeComponent I have: AddHandler Me.BrandSearch.SelectedIndexChanged, New EventHandler(AddressOf Me.BrandSearch_SelectedIndexChanged) in the handler I have: Private Sub BrandSearch_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BrandSearch.SelectedIndexChanged Trace.Write("leftcolumNav", "insided index changed handler") End Sub Page Trace shows new value in variable, but the trace in event handler doesn't appear. Using .NET 1.1 Any suggestions would be greatly appreciated. Is it possible that you're rebuilding the list upon postback. This could
cause it to lose memory of the event, so to speak. -Brock DevelopMentor http://staff.develop.com/ballen Show quoteHide quote > My dropdown list with autopostback set to true is returning to the > application but my even handler for selectedIndexChanged isn't firing. > in InitializeComponent I have: > AddHandler Me.BrandSearch.SelectedIndexChanged, New > EventHandler(AddressOf > Me.BrandSearch_SelectedIndexChanged) > in the handler I have: > Private Sub BrandSearch_SelectedIndexChanged(ByVal sender As > System.Object, > ByVal e As System.EventArgs) Handles BrandSearch.SelectedIndexChanged > Trace.Write("leftcolumNav", "insided index changed handler") > End Sub > Page Trace shows new value in variable, but the trace in event handler > doesn't appear. > > Using .NET 1.1 > > Any suggestions would be greatly appreciated. > Thanks for you reply, Brock.
I tried it both ways. If I build the dropdownlist contents in Not IsPostBack then the original page just refreshes with an empty list. The event does not fire. I can test for changed index in IsPostBack but that's such a kludge. Note the dropdownlist control is inside an ascx file and so is the handler. I don't think that should matter. This is mod to StoreFront shopping cart which by definition is a PITA to work with ;) Thanks again. Show quoteHide quote "Brock Allen" wrote: > Is it possible that you're rebuilding the list upon postback. This could > cause it to lose memory of the event, so to speak. > > -Brock > DevelopMentor > http://staff.develop.com/ballen > > > > > My dropdown list with autopostback set to true is returning to the > > application but my even handler for selectedIndexChanged isn't firing. > > in InitializeComponent I have: > > AddHandler Me.BrandSearch.SelectedIndexChanged, New > > EventHandler(AddressOf > > Me.BrandSearch_SelectedIndexChanged) > > in the handler I have: > > Private Sub BrandSearch_SelectedIndexChanged(ByVal sender As > > System.Object, > > ByVal e As System.EventArgs) Handles BrandSearch.SelectedIndexChanged > > Trace.Write("leftcolumNav", "insided index changed handler") > > End Sub > > Page Trace shows new value in variable, but the trace in event handler > > doesn't appear. > > > > Using .NET 1.1 > > > > Any suggestions would be greatly appreciated. > > > > > > > I tried it both ways. If I build the dropdownlist contents in Not Unless you've disabled ViewState, then you should only build the DDL when > IsPostBack then the original page just refreshes with an empty list. > The event does not fire. I can test for changed index in IsPostBack > but that's such a kludge. Note the dropdownlist control is inside an > ascx file and so is the handler. I don't think that should matter. > This is mod to StoreFront shopping cart which by definition is a PITA > to work with ;) IsPostBack==false. So this wounds like to me you've disabled ViewState? If that's the case, then always build your DDL in Page_Init and you should see better results. -Brock DevelopMentor http://staff.develop.com/ballen Ok that was it, the original page had view state disabled. When I turned it
back on the dropdownlist event works. Thanks a bunch, I've spent hours on this rather simple mod! Show quoteHide quote "Brock Allen" wrote: > > I tried it both ways. If I build the dropdownlist contents in Not > > IsPostBack then the original page just refreshes with an empty list. > > The event does not fire. I can test for changed index in IsPostBack > > but that's such a kludge. Note the dropdownlist control is inside an > > ascx file and so is the handler. I don't think that should matter. > > This is mod to StoreFront shopping cart which by definition is a PITA > > to work with ;) > > Unless you've disabled ViewState, then you should only build the DDL when > IsPostBack==false. So this wounds like to me you've disabled ViewState? If > that's the case, then always build your DDL in Page_Init and you should see > better results. > > -Brock > DevelopMentor > http://staff.develop.com/ballen > > > > > > "then always build your DDL in Page_Init and you should see
> better results"....that's the one that did it for me! Wow, what a pain. That helped me a ton. Nothing else worked until I found this post. Thank! JoshShow quoteHide quote "Brock Allen" wrote: > > I tried it both ways. If I build the dropdownlist contents in Not > > IsPostBack then the original page just refreshes with an empty list. > > The event does not fire. I can test for changed index in IsPostBack > > but that's such a kludge. Note the dropdownlist control is inside an > > ascx file and so is the handler. I don't think that should matter. > > This is mod to StoreFront shopping cart which by definition is a PITA > > to work with ;) > > Unless you've disabled ViewState, then you should only build the DDL when > IsPostBack==false. So this wounds like to me you've disabled ViewState? If > that's the case, then always build your DDL in Page_Init and you should see > better results. > > -Brock > DevelopMentor > http://staff.develop.com/ballen > > > > > > Ok when I trace the postback SelectedIndex value I get -1. That implies that
the DropDownList object is no longer loaded with options. The options need to be loaded at dynamically in Page_Load and that works, because I see the options. Any suggestions on what I'm doing wrong? Thanks much. Show quoteHide quote "Brock Allen" wrote: > Is it possible that you're rebuilding the list upon postback. This could > cause it to lose memory of the event, so to speak. > > -Brock > DevelopMentor > http://staff.develop.com/ballen > > > > > My dropdown list with autopostback set to true is returning to the > > application but my even handler for selectedIndexChanged isn't firing. > > in InitializeComponent I have: > > AddHandler Me.BrandSearch.SelectedIndexChanged, New > > EventHandler(AddressOf > > Me.BrandSearch_SelectedIndexChanged) > > in the handler I have: > > Private Sub BrandSearch_SelectedIndexChanged(ByVal sender As > > System.Object, > > ByVal e As System.EventArgs) Handles BrandSearch.SelectedIndexChanged > > Trace.Write("leftcolumNav", "insided index changed handler") > > End Sub > > Page Trace shows new value in variable, but the trace in event handler > > doesn't appear. > > > > Using .NET 1.1 > > > > Any suggestions would be greatly appreciated. > > > > > >
LinkButton Control
Validator Control Change print orientation by website Image auto sizing in asp.net VS.NET 2003 using ASP.NET & VB.NET -- IDE design time problems? DataGrid SortCommand Event not fired on dynamically generated datagrid Empty column Syntax for "NULL" in asp.net How to make datagrid headders non Scrollable in a multi page contr DataGrid Question |
|||||||||||||||||||||||