473,732 Members | 2,207 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 2067
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
5050
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
5367
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
7765
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
3389
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
1675
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
1123
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
5073
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
4436
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
1788
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
8946
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8774
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
9447
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...
0
9181
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...
1
6735
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
6031
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
4809
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3261
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2721
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.