473,468 Members | 1,369 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

how to add events to custom control

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 renders HTML with radio buttons (the result is similar to a RadioButtonList). I would like to add events to the control, but being new to .NET I don't know where to start.
When the user changes selection by clicking another radio button, I would like to do a postback and process the selected data.
How do I do this?
Again, I have no idea even how to start and I couldn't find help on the MSDN Library.
Thanks
TIB

Nov 18 '05 #1
3 1682
Hi,

you have to declare an Event attribute and creating a subrotine that
contains the RaiseEvent statement like

Public Event Event1(s as Object, e As EventArgs)

subrotine:

Protected Sub OnEvent1(e As EventArgs)
RaiseEvent Event1(Me, EventArgs.Empty)
End Sub

and look the class IPostBackDataHandler that your class must inherit

Marcos Santos

"TIBM" <TI**@discussions.microsoft.com> escreveu na mensagem
news:9E**********************************@microsof t.com...
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 renders HTML with radio buttons (the result is similar to a
RadioButtonList). I would like to add events to the control, but being new
to .NET I don't know where to start. When the user changes selection by clicking another radio button, I would like to do a postback and process the selected data. How do I do this?
Again, I have no idea even how to start and I couldn't find help on the MSDN Library. Thanks
TIB

Nov 18 '05 #2
And in C#,

public event EventHandler MyEvent;

protected void OnMyEvent(object sender, System.EventArgs e)
{
if(MyEvent != null)
{
MyEvent(sender, e);
}
}

public void TestEvent()
{
OnMyEvent(this, EventArgs.Empty);
}

--
HTH

Kyril Magnos

"Marcos Santos (MOS)" <ma***********@softway.com.br> wrote in message
news:Oi**************@TK2MSFTNGP09.phx.gbl...
| Hi,
|
| you have to declare an Event attribute and creating a subrotine that
| contains the RaiseEvent statement like
|
| Public Event Event1(s as Object, e As EventArgs)
|
| subrotine:
|
| Protected Sub OnEvent1(e As EventArgs)
| RaiseEvent Event1(Me, EventArgs.Empty)
| End Sub
|
| and look the class IPostBackDataHandler that your class must inherit
|
| Marcos Santos
|
| "TIBM" <TI**@discussions.microsoft.com> escreveu na mensagem
| news:9E**********************************@microsof t.com...
| > 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 renders HTML with radio buttons (the result is similar to a
| RadioButtonList). I would like to add events to the control, but being new
| to .NET I don't know where to start.
| > When the user changes selection by clicking another radio button, I
would
| like to do a postback and process the selected data.
| > How do I do this?
| > Again, I have no idea even how to start and I couldn't find help on the
| MSDN Library.
| > Thanks
| > TIB
| >
|
|
Nov 18 '05 #3
Check out the documentation on RaisePostBackEvent method and
IPostBackEventHandler as well. You may want to capture the postback event
in your control, and raise the event that your page will see from within the
postback event of the control.

Dale

"TIBM" <TI**@discussions.microsoft.com> wrote in message
news:9E**********************************@microsof t.com...
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 renders HTML with radio buttons (the result is similar to a
RadioButtonList). I would like to add events to the control, but being new
to .NET I don't know where to start. When the user changes selection by clicking another radio button, I would like to do a postback and process the selected data. How do I do this?
Again, I have no idea even how to start and I couldn't find help on the MSDN Library. Thanks
TIB

Nov 18 '05 #4

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

Similar topics

1
by: Mark | last post by:
Hi, I'm writing user controls with custom events. I have a parent custom event that exposes some abstract methods and some custom events. I have also created some new user controls that...
3
by: jlea | last post by:
I've created a custom control based on TreeView and it handles several events, such as Mousedown. I added this custom control to the toolbox in another project, dragged the custom control to the...
7
by: Colin Young | last post by:
I have a UserControl that contains a calendar control. The calendar is not raising events (month navigation, date selections, etc.). I've checked that the OnSelectionChanged event has a handler...
4
by: Andy | last post by:
Alright, I am beyond confused here and need some guidance. I need a C# only sample. I have a simple Page and within it i am creating a user control (ascx). The user control contains textboxes,...
1
by: Shourie | last post by:
I've noticed that none of the child controls events are firing for the first time from the dynamic user control. Here is the event cycle. 1) MainPage_load 2) User control1_Load user clicks a...
5
by: | last post by:
I am wondering what the best method of attaching custom Events to custom WebUserControls are. I cannot seem to find the proper terminology to expand my research. Basicallly I have a custom user...
12
by: scsharma | last post by:
Hi, I am working on creating a webapplication and my design calls for creating main webform which will have menu bar on left hand side and a IFrame which will contain all the forms that are shown...
9
by: Rob | last post by:
When a custom control is used within a form, that control does not get events directly. I've run into this a couple times with both mouse and keyboard events. Ex: A custom control inherits from...
2
by: ahmed.maryam | last post by:
Hello Everyone, I designed a custom control that is entirely covered by a picture box. I then dragged this custom control onto a windows form application (called main) and I need to handle mouse...
2
by: Michal Valent | last post by:
I would like to fire some custom server control event before Page_Load event like this (from the trace of an aspx page) : Trace Information Category Message From First(s) From Last(s) aspx.page...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
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...
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
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 ...

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.