473,461 Members | 1,681 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Add Click Event to my WebCustomControl?

I have made a pretty small and simple webCustomerControl that basically just
renders some HTML tables... I want parts of this to be clickable to fire off
a "Click Event" that you can use as a developer, how do I do this?

best regards/
Lars Netzel
Nov 19 '05 #1
3 2543
"Lars Netzel" <tr*****@apa.se> wrote in message
news:O5**************@TK2MSFTNGP14.phx.gbl...
I have made a pretty small and simple webCustomerControl that basically
just renders some HTML tables... I want parts of this to be clickable to
fire off a "Click Event" that you can use as a developer, how do I do this?


Take a look at some of the following MSDN links:

Events in ASP.NET Server Controls
(http://msdn.microsoft.com/library/de...mscontrols.asp)
Processing Postback Data
(http://msdn.microsoft.com/library/de...ifications.asp)

Capturing Postback Events
(http://msdn.microsoft.com/library/de...ifications.asp)

Bubbling an Event
(http://msdn.microsoft.com/library/de...mmandevent.asp)

Generating Client-Side Script for Postback
(http://msdn.microsoft.com/library/de...orpostback.asp)

John Saunders


Nov 19 '05 #2
Found it!

http://msdn.microsoft.com/library/de...ustomevent.asp
"Lars Netzel" <tr*****@apa.se> skrev i meddelandet
news:O5**************@TK2MSFTNGP14.phx.gbl...
I have made a pretty small and simple webCustomerControl that basically
just renders some HTML tables... I want parts of this to be clickable to
fire off a "Click Event" that you can use as a developer, how do I do this?

best regards/
Lars Netzel

Nov 19 '05 #3
Hi Lars!

CustomControl is basicaly Class and classes can have events. If you have
worked with properties in ASCX you know, that you have to publish properties
from your control and so is with events:

part of x.ASCX.vb file:
' Declare custom event
Public Event myButtonClick(ByVal sender As System.Object, ByVal e As
System.EventArgs)
' Handel event on ASCX
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
'Raise your event
RaiseEvent myButtonClick(Me, e)
End Sub

Then you have known issue by using this ascx on ASPX. Namely when you drag
ASCX control on your page Visual Studio .NET 2003 does not declare varibales,
so you have to do it by hand and then you can use your events:

part of code on x.ASPX.vb:
' First declare variable with the same name as ID of your web custom control
Protected WithEvents clickable1 As Clickable

' then you can use events
Private Sub clickable1_myButtonClick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles clickable1.myButtonClick
Response.Write("Yeah")
End Sub

That's all. If you think that code is not readable enough I can send you
sample project.

Dusan Zupancic

"Lars Netzel" wrote:
I have made a pretty small and simple webCustomerControl that basically just
renders some HTML tables... I want parts of this to be clickable to fire off
a "Click Event" that you can use as a developer, how do I do this?

best regards/
Lars Netzel

Nov 19 '05 #4

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

Similar topics

2
by: Pete | last post by:
I have some funky form/event behavior. Access 97. Split frontend/backend, using Access security. I have the same behavior (or lack of behavior) for the pag_Click() event of two separate pages...
2
by: Tamir Khason | last post by:
I build user control, consists of different things (e.g label, image, etc.) I want to handle click (and other) events, however I can not do it until I do not assign event handler for each control...
6
by: Michael Johnson Jr. | last post by:
I am trying to handle a button click event, which updates a web control table with data. The button is dynamically created in the table itself. When I call updateTable() in the Page_Load the new...
5
by: J McD | last post by:
Hi I have a DataGrid with an ImageButton column. When I click on an imagebutton I get a postback but it doesn't run the OnImgBtnClick method. I can actually comment out the line where I add this...
41
by: JohnR | last post by:
In it's simplest form, assume that I have created a usercontrol, WSToolBarButton that contains a button. I would like to eventually create copies of WSToolBarButton dynamically at run time based...
2
by: Mattbooty | last post by:
Hello, Not sure if anyone else has seen this bug, but I have a form where the entire form is covered with a picturebox. The picturebox has a mouseup event. I also have an open file dialog for...
0
by: Demetri | last post by:
I have created a web control that can be rendered as either a linkbutton or a button. It is a ConfirmButton control that allows a developer to force a user to confirm if they intended to click it...
2
by: Chu | last post by:
Thanks everyone for taking a moment to read this. I've got a page where I use a LinkButton and I wire up a dynamic event to the button. When the user clicks the button, the event is fired as...
3
by: Robert W. | last post by:
I'm new to ASP.net programming so excuse my ignorance if the following question seems overly simplistic. I've created a simple Login form with 3 primary WebControls: - A TextBox for the Username...
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
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...
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: 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
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
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.