473,396 Members | 1,785 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,396 software developers and data experts.

handling a button's click event

PJ6
I've added a button to a class inheriting from System.Web.UI.Control and
want to handle (pass on) its click event to the page that contains it.

Coming from a WinForms background, I thought this (below) would work. It
doesn't. A break point on btn_Click isn't even hit.

Is there a way to do this?

Paul

Private Sub btn_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btn.Click
Me.OnClick(New EventArgs)
End Sub

Public Event Click(ByVal sender As Object, ByVal e As EventArgs)

Protected Overridable Sub OnClick(ByVal e As EventArgs)
RaiseEvent Click(Me, e)
End Sub

Nov 19 '05 #1
3 2659
PJ6,

Without knowing what your control contains this is difficult... But, a short
answer might be to do the following:

Would you be able to inherit from a button instead of just a generic
control? Then you'd have all the postback hookup code inherent in the object
instead of having to create it yourself...

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"PJ6" <no****@nowhere.net> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
I've added a button to a class inheriting from System.Web.UI.Control and
want to handle (pass on) its click event to the page that contains it.

Coming from a WinForms background, I thought this (below) would work. It
doesn't. A break point on btn_Click isn't even hit.

Is there a way to do this?

Paul

Private Sub btn_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btn.Click
Me.OnClick(New EventArgs)
End Sub

Public Event Click(ByVal sender As Object, ByVal e As EventArgs)

Protected Overridable Sub OnClick(ByVal e As EventArgs)
RaiseEvent Click(Me, e)
End Sub

Nov 19 '05 #2
PJ6
What I have now is a table with one row with three cells. Each cell has some
"pretty" background in it, and in the center cell there is some text, or, if
need be, a real button. It's essentially a customized button that should act
like a button control.

I could in theory inherit button and override render, but I think that still
leaves me with a problem - this control needs to raise a click event
server-side in its containing form. Yes, I can manually raise the click
event in with OnClick, but from where do I fire that? A contained button's
click event? That doesn't work, the control - whether it be inherited from
Control or Button - refuses to handle it.

Please tell me about postback hookup code.

Paul

"S. Justin Gengo" <justin@[no_spam_please]aboutfortunate.com> wrote in
message news:ea*************@TK2MSFTNGP10.phx.gbl...
PJ6,

Without knowing what your control contains this is difficult... But, a
short answer might be to do the following:

Would you be able to inherit from a button instead of just a generic
control? Then you'd have all the postback hookup code inherent in the
object instead of having to create it yourself...

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"PJ6" <no****@nowhere.net> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
I've added a button to a class inheriting from System.Web.UI.Control and
want to handle (pass on) its click event to the page that contains it.

Coming from a WinForms background, I thought this (below) would work. It
doesn't. A break point on btn_Click isn't even hit.

Is there a way to do this?

Paul

Private Sub btn_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btn.Click
Me.OnClick(New EventArgs)
End Sub

Public Event Click(ByVal sender As Object, ByVal e As EventArgs)

Protected Overridable Sub OnClick(ByVal e As EventArgs)
RaiseEvent Click(Me, e)
End Sub


Nov 19 '05 #3
PJ6,

This article will explain what you need to do:

http://msdn.microsoft.com/library/de...EventModel.asp
--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"PJ6" <no****@nowhere.net> wrote in message
news:Ob**************@TK2MSFTNGP12.phx.gbl...
What I have now is a table with one row with three cells. Each cell has
some "pretty" background in it, and in the center cell there is some text,
or, if need be, a real button. It's essentially a customized button that
should act like a button control.

I could in theory inherit button and override render, but I think that
still leaves me with a problem - this control needs to raise a click event
server-side in its containing form. Yes, I can manually raise the click
event in with OnClick, but from where do I fire that? A contained button's
click event? That doesn't work, the control - whether it be inherited from
Control or Button - refuses to handle it.

Please tell me about postback hookup code.

Paul

"S. Justin Gengo" <justin@[no_spam_please]aboutfortunate.com> wrote in
message news:ea*************@TK2MSFTNGP10.phx.gbl...
PJ6,

Without knowing what your control contains this is difficult... But, a
short answer might be to do the following:

Would you be able to inherit from a button instead of just a generic
control? Then you'd have all the postback hookup code inherent in the
object instead of having to create it yourself...

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"PJ6" <no****@nowhere.net> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
I've added a button to a class inheriting from System.Web.UI.Control and
want to handle (pass on) its click event to the page that contains it.

Coming from a WinForms background, I thought this (below) would work. It
doesn't. A break point on btn_Click isn't even hit.

Is there a way to do this?

Paul

Private Sub btn_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btn.Click
Me.OnClick(New EventArgs)
End Sub

Public Event Click(ByVal sender As Object, ByVal e As EventArgs)

Protected Overridable Sub OnClick(ByVal e As EventArgs)
RaiseEvent Click(Me, e)
End Sub



Nov 19 '05 #4

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

Similar topics

4
by: John Fereira | last post by:
So, one of the limitations of multipart-form handling is that when an <input type="file" ..> tag is used it will bring up a window which allows a user to select a file for upload but won't allow...
2
by: Marinos Christoforou | last post by:
Sorry if this has been asked before but as an inexperienced wanna-be C# programmer I wondering how to code classes to help build a standard Windows UI. For example to build a common toolbar. I...
2
by: Eric Newton | last post by:
VB's more declarative nature of handling events is golden. I'm hoping C# will acquire this type of deal, in addition to the anonymous delegates. could do same as vb (actually would be easier to...
0
by: luca | last post by:
Hi all. My problem is that I can't handle events raised from child components within a composite server control when the control is created dynamically. Everything works fine if the same control...
12
by: Jack Russell | last post by:
My unstanding of all VB up to and including vb6 is that an event could not "interrupt" itself. For instance if you had a timer event containing a msgbox then you would only get one message. ...
11
by: chopsnsauce | last post by:
Here's the example: Dim frm As New FORM1 Try frm.show Catch ex As Exception msgbox ex.message
8
by: Louis | last post by:
I was trying to display a custom context menu in javascript. I wanted to capture a right mouse click. I added an eventListener to a "div" like this.. element,addEventListener ("click", myfunc,...
1
by: raghulvarma | last post by:
I have created a custom control to get the values and sum them, Here I am able to get display the controls but I am not able to add the values in the text box which means that I am not able to catch...
5
by: Klaudiusz Bryja | last post by:
Hi, This is for NetCF 2.0. I need to create event handling code which using reflection. I have some parameters in XML which describe how event should be handled. I have code to create...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
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,...

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.