473,586 Members | 2,681 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Add Click Event to my WebCustomContro l?

I have made a pretty small and simple webCustomerCont rol 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 2549
"Lars Netzel" <tr*****@apa.se > wrote in message
news:O5******** ******@TK2MSFTN GP14.phx.gbl...
I have made a pretty small and simple webCustomerCont rol 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******** ******@TK2MSFTN GP14.phx.gbl...
I have made a pretty small and simple webCustomerCont rol 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(B yVal sender As System.Object, ByVal e As
System.EventArg s)
' Handel event on ASCX
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
'Raise your event
RaiseEvent myButtonClick(M e, 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_myBu ttonClick(ByVal sender As Object, ByVal e As
System.EventArg s) Handles clickable1.myBu ttonClick
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 webCustomerCont rol 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
21983
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 on different menu forms. Details: frmTRNMenu is the main menu of the application. It uses tabbed pages to logically separate menu items. The...
2
29069
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 inside me user contol. Is there way to do this "smart" just inherit all possible events from usercontrol class instead of rewriting custom handlers...
6
2835
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 data from the button is not available at this time as to allow the table to properly update. So basically, I need to call UpdateTable() twice, once...
5
6166
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 Click event to the ImageButton Column and it makes no difference, I still get a postback. This is driving me crazy...something seems to be causing...
41
4280
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 on some initialization information obtained elsewhere. Basically, I'm going to create my own dynamic toolbar where the toolbarbuttons can change. ...
2
6130
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 loading images into the picturebox. If you double click the file you want to open in the open file dialog, it somehow interperets one of the clicks...
0
2939
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 such as when they do a delete. Everything is great. By and large it will be used in my repeater controls using the command event when the user...
2
2372
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 expected. In the event code for that button, a new LinkButton is added to the page and is wired up to yet a different event, however when clicked, the...
3
4261
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 - A TextBox for the Password - A Button labelled "Submit" If the user enters a correct username/password combination then he's taken to another...
0
7912
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7839
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...
0
8338
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8216
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...
0
6614
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...
0
3837
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...
1
2345
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
1
1449
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.