473,761 Members | 8,463 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

OnSelectedIndex Changed does not fire with inherited Page class

I have a simple page that has a dropdown with autopostback=tr ue and
onselectedindex changed is set to a function that never gets called
(checked during debug). This page is subclassed from custom class of
mine that I subclassed from Page.

I have overridden a couple of methods (OnPreRender, OnUnload, OnInit)
to provide for html template layout, all of the base functions are
called as well.

Can anyone lend some help as to why the SelectedIndexCh anged event does
not fire when you use a custom Page class? I have to be doing something
in the custom code to prevent the event from firing, I just don't know
where.

Thanks a ton!
Stuart

Nov 19 '05 #1
6 2071
Are you binding the dropdownlist in page_load without check for ispostback()
property.

--
-Saravana
http://dotnetjunkies.com/WebLog/saravana/
www.ExtremeExperts.com

<sr*****@gmail. com> wrote in message
news:11******** *************@c 13g2000cwb.goog legroups.com...
I have a simple page that has a dropdown with autopostback=tr ue and
onselectedindex changed is set to a function that never gets called
(checked during debug). This page is subclassed from custom class of
mine that I subclassed from Page.

I have overridden a couple of methods (OnPreRender, OnUnload, OnInit)
to provide for html template layout, all of the base functions are
called as well.

Can anyone lend some help as to why the SelectedIndexCh anged event does
not fire when you use a custom Page class? I have to be doing something
in the custom code to prevent the event from firing, I just don't know
where.

Thanks a ton!
Stuart

Nov 19 '05 #2
Stu
no, I do a check for IsPostBack with the Bind call...

I've narrowed the problem down some.

By overriding OnPreRender or OnLoad, somehow this causes the event not
to fire.

I moved all my templating code to OnInit and now I can get the event to
fire, its just that my template code is dependent on Session varaibles,
which are changed by the dropdown, so the session object isn't changed
when OnInit is run, only after OnLoad....

frustrated...

Nov 19 '05 #3
Hello Stu,

I've had this happen for me if the Value property is not unique... Make sure
that if you're using ValueMember that each item in your datasource has that
property unique.

--
Matt Berther
http://www.mattberther.com
I have a simple page that has a dropdown with autopostback=tr ue and
onselectedindex changed is set to a function that never gets called
(checked during debug). This page is subclassed from custom class of
mine that I subclassed from Page.

I have overridden a couple of methods (OnPreRender, OnUnload, OnInit)
to provide for html template layout, all of the base functions are
called as well.

Can anyone lend some help as to why the SelectedIndexCh anged event
does not fire when you use a custom Page class? I have to be doing
something in the custom code to prevent the event from firing, I just
don't know where.

Thanks a ton!
Stuart

Nov 19 '05 #4
Stu
Thanks for the suggestion.. that wasn't it... If the set the page that
has the dropdown to use the regular Page class, the event will fire.

Nov 19 '05 #5
Stu
I re-worded the problem, perhaps this will help:
Ok here is the situation:

I have inherited System.Web.UI.P age into a custom class for page
templating.

For my template html, I create several LiteralControls and add them to
the controls collection. works fine.

Initially I placed this code in the OnInit method. Works good.
Part of my template code now displays a Session variable, this is part
of the problem.

A page that inherits the custom class has a DropDownList with
autopostback=tr ue and OnSelectedIndex Changed event set to fire.
In the event, I change the value of that Session variable.
But since the template code is calling in OnInit, the page shows the
old session variable, you have to refresh the page to get the page to
show the latest session variable, this is bad.

So, I tried moving my template html controls to another overridable
method, moved it all to OnPreRender.
So, now, my OnSelectedIndex Changed event doesn't fire, b/c the
DropDownList does something screwy with the PreRender method.

So here in summary:
Need custom class to inherit Page class for templating.
Templated HTML material needs access to Session variables. (in what
override should this code live in?)
DropDownList needs to fire SelectedIndexCh anged event to change Session
variable.
(how does the prior affect this, where can I put the prior so it
doesn't screw up the event from firing?)

Any ideas?

Nov 19 '05 #6
Hello Stu,

Any possibility you could post the code that you have now that doesnt work?
We may be able to see something there...

--
Matt Berther
http://www.mattberther.com
I re-worded the problem, perhaps this will help:

Ok here is the situation:

I have inherited System.Web.UI.P age into a custom class for page
templating.

For my template html, I create several LiteralControls and add them to
the controls collection. works fine.

Initially I placed this code in the OnInit method. Works good.
Part of my template code now displays a Session variable, this is part
of the problem.
A page that inherits the custom class has a DropDownList with
autopostback=tr ue and OnSelectedIndex Changed event set to fire.
In the event, I change the value of that Session variable.
But since the template code is calling in OnInit, the page shows the
old session variable, you have to refresh the page to get the page to
show the latest session variable, this is bad.
So, I tried moving my template html controls to another overridable
method, moved it all to OnPreRender.
So, now, my OnSelectedIndex Changed event doesn't fire, b/c the
DropDownList does something screwy with the PreRender method.
So here in summary:
Need custom class to inherit Page class for templating.
Templated HTML material needs access to Session variables. (in what
override should this code live in?)
DropDownList needs to fire SelectedIndexCh anged event to change
Session
variable.
(how does the prior affect this, where can I put the prior so it
doesn't screw up the event from firing?)
Any ideas?

Nov 19 '05 #7

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

Similar topics

13
5053
by: Jason Huang | last post by:
Hi, Would someone explain the following coding more detail for me? What's the ( ) for? CurrentText = (TextBox)e.Item.Cells.Controls; Thanks. Jason
2
5369
by: Julie Barnet | last post by:
I have a dropdownlist. It does not fire the selected index changed event when it should. I also have a submit button on my page, and when it is clicked, it does fire the selectedindexchanged event of the dropdownlist. What am I doing wrong? mbcbb:combobox is a user control combining the funcitonality of a dropdownlist and a textbox. aspx <mbcbb:combobox Runat="Server"
6
7770
by: DotNetGruven | last post by:
I have a webform that has a DataGrid on it with a RadioButtonList in each row. It is a simple On & Off. When the User Clicks on either of the RadioButtons, I need to postback to the server and update the database. Here is the control containment hierarchy: ASP Page Static User Control // just provides a pretty border around
1
3391
by: bminder | last post by:
In the asp.net pages below, Common.vb has an overridable Page_Load sub. In the consuming page, Two.aspx, the Page_Load sub is inherited, but for some reason it (Overrides Sub Page_Load) executes twice. In another "regular" asp.net page that inherits only from its own codebehind page, the page load only executes once as you'd expect. Any ideas why the page_load fires twice in the former example? Thanks,
4
1678
by: James Hancock | last post by:
I have a page, which is inherited from another page (PageEx is what I call it) All of our pages are based on PageEx because there is a bunch of logic stuff we do in there. My problem is, that if I have a page that is inherited from PageEx, the post back events don't get called on the page. If I put back the page to inherit from UI.Page everything is fine except we don't have database settings etc. Anyone have any ideas? Thanks!
0
1126
by: Stuart Allen | last post by:
I have a custom class that inherits System.Web.UI.Page for use with all my pages. On a page I'm trying to use a DropDownList. I have autopostback=true and have a method defined for the OnSelectedIndexChanged event, but this event never fires when using my custom class. The dropdownlist is populated from a DB using a BindData function that I call in Page_Load where I check for IsPostBack, so thats not the issue. In my class I have...
1
5076
by: RedGST | last post by:
Hello, Im somewhat new to asp.net, so bear with me. I have created a form that has a Listbox along with 2 command buttons & a few other non-important controls. The command button is tied to the OnClick Event. My problem is that when the command button is clicked, the Listbox OnSelectedIndexChanged event gets fired before the command buttons OnClick
1
4439
by: Paul L | last post by:
Hi, I have an issue with the OnSelectedIndexChanged event not firing for a DropDownList control which is in the ItemTemplate of a DataList. I have made an exact copy of the DropDownList control, and placed it outside of the DataList and it fires the event just fine. So it's definitely to do with it being in a template. I've managed to reproduce the issue on a small test app, the code and html is below:
3
1789
by: Jeff User | last post by:
Hello I am using C#, .net1.1 Vis Studio 2003 I am using homeBase.aspx.cs page as a base for several other aspx/aspx.cs web pages. The base page handles some operations that are common to all pages. like this: somepage... public class homeBase : System.Web.UI.Page .... then other pages.....
0
9336
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10111
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9902
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9765
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8770
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7327
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6603
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5215
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
3446
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.