473,405 Members | 2,262 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Custom Control RaiseEvent

I cannot figure out what I'm doing wrong, can someone shed some light on
this for me?

I have the following code inside a working user control (MyControl):

Public Event SubmitClick(ByVal sender As Object, ByVal e As EventArgs)
Private Sub btnSubmit_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnSubmit.Click

RaiseEvent SubmitClick(sender, e)

End Sub

In the code-behind of the calling page I have this:

Protected WithEvents ctrlMyControl As MyControl
Private Sub ctrlMyControl_SubmitClick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles ctrlMyControl.SubmitClick

End Sub

When I run it through the debugger, the RaiseEvent line fires, but none of
the code in the code-behind runs.

Thanks in advance for any assistance you can lend!

Nov 21 '05 #1
3 3258

Make sure the instance of MyControl which is raising the event is in
the same place where you have placed the handler.

-Pamela
..NET Developer
http://151.100.3.84/technicalpreview/

ps
probably the full code would make more clear what you are doing. In
case, try also declaring the event as SHARED to see
if it is a scope problem.

Nov 21 '05 #2
Thank you for the asssitance.
I have found some additional information.

I am currently using the custom control in the EditItemTemplate of a
datalist. When I pull the control out of the datalist, the events fire
perfectly.
What am I missing in order to wire up the events when using it in the
EditItemTemplate.

I tried adding this code to the EditCommand routine:

AddHandler MyControl.SubmitClick, AddressOf ctrlMyControl_SubmitClick

But received an "object not set to an instance" error.
Thanks again for any assistance!
Nov 21 '05 #3
Check if you have a duplicate construction
something like:

dim withevents Control as new control
control = new control

so that the instance which you are passing the delegate
is not the same which is used later on ...
-Pamela
..NET Developer
http://151.100.3.84/technicalpreview/

Nov 21 '05 #4

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

Similar topics

4
by: Steve Amey | last post by:
Hi all I am creating a basic control to perform some tasks, and I want to declare some events to be raised so they can be handled from the form that the control is on. I can create my own Event...
3
by: TIBM | last post by:
Hi. I'm not getting any answers in buildingcontrols, so I'm gonna try here. I've written a custom control derived from System.Web.UI.WebControls.ListControl. The control is taking in a dataset and...
6
by: grist2mill | last post by:
I want to create a standard tool bar that appears on all pages that is a control. The toolbar has a button 'New'. What I wolud like when the user clicks on 'New' depends on the page they are on. I...
2
by: bretth | last post by:
In a VB.Net Windows Forms application, I have a user control that handles mouse events. Another section of code programmatically adds a label to the control. I would like label to ignore all...
0
by: Brian Henry | last post by:
Ok I've never implemented a snap location before so I dont really know what im doing wrong here... anyways, I am making a custom slider control that takes dates as its values instead of integers......
4
by: Jon Paal | last post by:
I have a custom server control which renders some html. I want to capture some interim values generated by the control as it processes the data. is there a way to capture and retrieve the...
5
by: rn5a | last post by:
Consider the following user control which resides in Address.ascx: <script runat="server"> Public Property Address() As String Get Address = txtAddress.Text End Get Set(ByVal value As String)...
0
by: ChopStickr | last post by:
I have a custom control that is embedded (using the object tag) in an html document. The control takes a path to a local client ini file. Reads the file. Executes the program specified in...
2
by: pdickson | last post by:
Hi - I am using custom textboxes and I need to be able to set the Text on txb1 based on the Text of txb2. I have simplied my code to the following: Public Class customtextbox Inherits...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
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...
0
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,...
0
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...

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.