Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Professional
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 23rd, 2004, 11:27 AM
Registered User
 
Join Date: Jan 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to thanie2001
Default Events firing for control in one instance, but...

Maybe someone has run across this problem before:

I have an ASP.NET/VB.NET application where a particular user control is giving me some erratic behavior.

The instance of the control that works is first loaded in another user control before it is loaded into the final page.
The instance of the control that doesn't work is simply loaded into the same page as the other embedded instance.
The user control has a drop down list with autopostback set to true. In the embedded instance, the SelectedIndexChanged event handler runs without a problem and passes back the list's SelectedIndex property exactly as it should.
In the instance residing in the page, the SelectedIndexChange event handler never runs and always passes back a SelectedIndex property value of 0, no matter which value I actually select.

Does anything here really jump out at anybody here? Has anybody here experienced something similar? This is driving me nuts at this point...

Thanks,
thanie2001
 
Old January 23rd, 2004, 02:15 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

How are the controls getting into place? Are they in the markup or are you adding them programmatically. Can you post the relevant code?
 
Old January 23rd, 2004, 02:29 PM
Registered User
 
Join Date: Jan 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to thanie2001
Default

Here is the registration on the page:

<%@ Register TagPrefix="uc1" TagName="ctlBrowse" Src="ctlBrowse.ascx" %>

And here are the declarations of the objects:
<uc1:ctlbrowse id="ctlBrowseBrand" runat="server"></uc1:ctlbrowse>
<uc1:ctlbrowse id="ctlBrowseModel" runat="server"></uc1:ctlbrowse>
<uc1:ctlbrowse id="ctlDealers" runat="server">

I'm calling the controls programmatically like this:

This is the one that works:
Declaration:
Private WithEvents Dlrs As <projectname>.ctlBrowse
Assignment of variable:
Dlrs = Me.FindControl("ctlDealers")
These assignments are nested one layer deep from the calling page.

These are the ones that don't work:
Declaration:
Private WithEvents oBrands As ctlBrowse
Private WithEvents oModels As ctlBrowse
Assignments:
oBrands = Page.FindControl("ctlbrowseBrand")
oModels = Page.FindControl("ctlBrowseModel")

Here is the declaration of the event handler from the control that fires in the first instance, but not in the other:

Private Sub ItemWasSelected(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ddValues.SelectedIndexChanged

Does this help or do you need more?
 
Old January 23rd, 2004, 03:01 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You shouldn't need to find the controls. Usually the declaration for markup based controls in the codebehind looks like this:

Protected WithEvents ...

Perhaps this is why you are having to FindControl() them. This doesn't explain however why one works and 2 don't.

I don't understand what you mean by "These assignments are nested one layer deep from the calling page."

From what you have so far posted, I am thinking that you want to handle the user control's dropdown changed event on the page. Is this correct? If so, then you need to do this a different way. You should create a public event on the user control, and raise this event in the event handler of the dropdown. Then the page will handle the user control's event that you raised.

Look about half way down this thread for a cheesy little drawing of mine that shows event bubbling.

Peter
------------------------------------------------------
Work smarter, not harder.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with events not firing Keith Smith Excel VBA 2 August 3rd, 2016 05:39 PM
Events are not firing msrnivas .NET Web Services 14 April 21st, 2008 06:37 AM
Events not firing in IE malk ASP.NET 1.0 and 1.1 Professional 7 August 29th, 2006 01:32 PM
Windows control events not firing bmains C# 2005 2 June 5th, 2006 09:11 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.