473,507 Members | 9,962 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Button inside a custom control...

Hi boys..
....i've a question for you!

I've a custom control with a button.
Well...
I need to create that:

<mytagprefix:mytag runat="server" onButtonClick="Button_Click">

And in the code behind of this page, i find the Button_Click function.

Ok...
....but how to implements the onButtonClick event in the control side?
What i must do to obtain it?

Please reply me...

....thanx.
tranky
Sep 5 '06 #1
1 1494
hi,
basically your control has hidden the functionality of the button from the
page containing the control. if you want to access the events of the
button, then you can do 2 things:

in the control, make the button public, and then in the page you can
programatically access the button through the control, and add an event
handler to it as follows:
this.Control1.Button1.Click += new EventHandler(myButtonClick);

OR

you can create a new public event in the control called onButtonClick. this
event will be raised whenever the button click happens, so in a sense it is
'forwarding' the button click event to your new event. with this approach,
your page can use the declarative syntax you have posted below, without
needing to dig into the control to get the button and wire up and event to
it.

i hope this helps
tim
"tranky" <NO****@GRAZIE.itwrote in message
news:44***********************@reader3.news.tin.it ...
Hi boys..
...i've a question for you!

I've a custom control with a button.
Well...
I need to create that:

<mytagprefix:mytag runat="server" onButtonClick="Button_Click">

And in the code behind of this page, i find the Button_Click function.

Ok...
...but how to implements the onButtonClick event in the control side?
What i must do to obtain it?

Please reply me...

...thanx.
tranky

Sep 6 '06 #2

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

Similar topics

1
3539
by: Robert Neville | last post by:
I am having some trouble with some old code revolving around custom form navigation buttons. My main form has a sub-form with these custom navigation buttons. In other words, the code should be...
3
3225
by: KJ | last post by:
I have seen examples on how to set the default button on a ASPX page with asp server controls Sub Page_Load() Page.RegisterHiddenField("__EVENTTARGET", "btnSearch") End Sub But that does...
0
1276
by: panik | last post by:
Hi, I have a Control, a SearchBox class, that is derived from UserControl. It is placed inside another UserControl (a page structure) that is placed inside a custom page class (derived from...
0
1243
by: sonic | last post by:
hello, I have this custom datagrid control, that inherits from DataGrid. In addition to datagrid, I am adding a "status" table under it, and another html button, which will trigger a new row. ...
1
2607
by: Martin | last post by:
Hi, I have produced a custom server control that simple outputs a row of 26 buttons, one button for each letter of the english alphabet. now what I would like to do is catch the button click...
1
3194
by: rn5a | last post by:
I want to create a custom control that encapsulates a Button & a TextBox. When the Button is clicked, the user is asked a question using JavaScript confirm (which shows 2 buttons - 'OK' &...
1
1946
by: shapper | last post by:
Hello, I am creating a custom control where I have a button. Somehow my button click event is not being raised. I tried to place different codes inside MyButton_Click and nothing runs. Then I...
5
2809
by: gregarican | last post by:
There is a C# CTI app I'm working on using Visual Studio 2005 at revision level 8.0.50727-7600. I need a couple of Windows Form Button controls to emulate line buttons on a telephone. So I went to...
17
10292
by: govolsbaby | last post by:
Is there a way to leave the button forecolor unchanged when it is disabled? I have multiple buttons on the form and depending on various user inputs, some will or will not be enabled but I'd...
0
7221
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
7313
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,...
1
7029
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
7481
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
5619
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
4702
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...
0
3190
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...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1537
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.