Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Closed Thread
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old February 22nd, 2007, 10:18 AM
cornelis79's Avatar
cornelis79 cornelis79 is offline
.
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2005
Location: Netherlands
Posts: 55 cornelis79 User rank is Corporal (100 - 500 Reputation Level)cornelis79 User rank is Corporal (100 - 500 Reputation Level)cornelis79 User rank is Corporal (100 - 500 Reputation Level)cornelis79 User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 21 h 50 m 25 sec
Reputation Power: 6
How to identify object that raised event

Hi,

I know you can trigger one event by multiple objects like:

Code:
Private Sub Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click, Button2.Click, Button3.Click 'etc, etc

    End Sub


My question is how can I identify which button triggered this event?

Because I would expect something like "sender.name"
But the only "useful" property is sender.ToString

But if you check that string I get something like:

Code:
System.Windows.Forms.Button, Text: Test button


In the string I cannot find the object's ID.
In case of a button you could filter out the "Text" part in this string, but it won't work if you have an input field.

So..., how do I know which object triggered the event?

Thanks in advance.

Reply With Quote
  #2  
Old February 23rd, 2007, 06:30 AM
sync_or_swim's Avatar
sync_or_swim sync_or_swim is offline
Moderator
Click here for more information.
 
Join Date: Mar 2006
Location: South Wales
Posts: 1,932 sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 6 Days 22 h 36 m 35 sec
Reputation Power: 1243
Hi,

Try something like this:
Code:
Private Sub Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim ID As String
ID = CType(Sender, Button).UniqueID

'etc....

End Sub

Reply With Quote
  #3  
Old February 23rd, 2007, 06:42 AM
cornelis79's Avatar
cornelis79 cornelis79 is offline
.
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2005
Location: Netherlands
Posts: 55 cornelis79 User rank is Corporal (100 - 500 Reputation Level)cornelis79 User rank is Corporal (100 - 500 Reputation Level)cornelis79 User rank is Corporal (100 - 500 Reputation Level)cornelis79 User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 21 h 50 m 25 sec
Reputation Power: 6
Thank you for your help.

I already got a similar solution:

Code:

Dim triggerObj as string
Dim btn as Button
btn = DirectCast(sender, button)
triggerObj = btn.name

...

Reply With Quote
  #4  
Old February 24th, 2007, 07:27 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
ASP Free God 46th Plane (27500 - 27999 posts)
 
Join Date: Sep 2004
Location: Israel
Posts: 27,932 Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)  Folding Points: 391471 Folding Title: Super Ultimate Folder - Level 1Folding Points: 391471 Folding Title: Super Ultimate Folder - Level 1Folding Points: 391471 Folding Title: Super Ultimate Folder - Level 1Folding Points: 391471 Folding Title: Super Ultimate Folder - Level 1Folding Points: 391471 Folding Title: Super Ultimate Folder - Level 1Folding Points: 391471 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 2 Weeks 12 h 17 m 53 sec
Reputation Power: 2002
Thumbs down

yeah, the duplicate thread can be found here:
http://forums.aspfree.com/showthread.php?p=459437
--thread closed, thumbs down.
Comments on this post
Nilpo agrees: Nice catch.

Reply With Quote
Closed Thread

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > How to identify object that raised event


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT