By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,678 Members | 1,158 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,678 IT Pros & Developers. It's quick & easy.

how to add events to custom control

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.