473,657 Members | 2,559 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to add events to custom control

Hi. I'm not getting any answers in buildingcontrol s, so I'm gonna try here.

I've written a custom control derived from System.Web.UI.W ebControls.List Control. 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 1690
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 IPostBackDataHa ndler that your class must inherit

Marcos Santos

"TIBM" <TI**@discussio ns.microsoft.co m> escreveu na mensagem
news:9E******** *************** ***********@mic rosoft.com...
Hi. I'm not getting any answers in buildingcontrol s, so I'm gonna try here.
I've written a custom control derived from System.Web.UI.W ebControls.List Control. 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(objec t sender, System.EventArg s 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******** ******@TK2MSFTN GP09.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 IPostBackDataHa ndler that your class must inherit
|
| Marcos Santos
|
| "TIBM" <TI**@discussio ns.microsoft.co m> escreveu na mensagem
| news:9E******** *************** ***********@mic rosoft.com...
| > Hi. I'm not getting any answers in buildingcontrol s, so I'm gonna try
| here.
| >
| > I've written a custom control derived from
| System.Web.UI.W ebControls.List Control. 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 RaisePostBackEv ent method and
IPostBackEventH andler 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**@discussio ns.microsoft.co m> wrote in message
news:9E******** *************** ***********@mic rosoft.com...
Hi. I'm not getting any answers in buildingcontrol s, so I'm gonna try here.
I've written a custom control derived from System.Web.UI.W ebControls.List Control. 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
7313
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 derive from the parent custom control and add some text boxes, labels, buttons etc...
3
549
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 form and everything works as it should with the custom control responding to the mousedown event. I also want to respond to the mousedown down event occuring in the custom control inside of the form containing the custom control. Does anyone know...
7
2680
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 being registered. Is there anything else obvious or otherwise that I've missed? Is there a problem using it in a UserControl? Thanks Colin
4
10114
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, buttons, ect. I would like to catch/add a handler/recieve the Button.OnClick event from the buttons that are in the user control, in the Page. How? As far as I can tell, my only route is to: RaiseBubbleEvent in the Button.OnClick in the...
1
7565
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 dropdown in UC1 _________________________ 1) MainPage_Load 2) User Control_1 Load
5
4534
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 control that has 2 or 3 events selectionChanged DropDownOpened I would like the user to be able to attach Server Side events for both. I have the client side implementation worked out. I just need to find a proper way to to get everything...
12
2785
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 when menu items are clicked.Besides these i would like to put a custom status bar. Any error message encountered in any of the webpage will be displayed in the banner. The problem iam encountering is how to access the customer status bar in child...
9
5116
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 UserControl (or Panel, etc). If that particular control is being edited, it IS possible to assign handlers and get events. However, when the control is used on the main form, assigning a handler to the particular control does nothing--the...
2
3251
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 events in my main application. Specifically, when a user double clicks on my custom control I need to draw something on another picture box located in my main application. I'm going to attempt to draw the scenario because I think it will
2
2734
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 Begin PreInit aspx.page End PreInit 5,38454603734274E-05 0,000054 aspx.page Begin Init 8,96405962016187E-05 0,000036 aspx.page End Init 0,00072941040948794 0,000640 aspx.page Begin InitComplete 0,000772971258380746 0,000044
0
8305
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
8825
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
8503
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
8605
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
7324
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...
0
5632
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
4151
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...
1
2726
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
1953
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.