Your full service technology partner! 
-Collapse +Expand
Search Prism Group:

-Collapse +Expand Prism To/From
-Collapse +Expand Prism Study Test
-Collapse +Expand Prism Store

Prestwood eMagazine

October Edition
Subscribe now! It's Free!
Enter your email:

   ► KBProgrammingDelphi PrismDelphi for ....   Print This     
  From the October 2008 Issue of Prestwood eMag
Prism Delphi for .Net Archive:
ASP.NET under Delphi
Posted 15 years ago on 5/3/2006 and updated 1/20/2009
Take Away:

use of Sender under Delphi for .NET


Let's say you have a DropDownList object on your ASP.NET form, and you want to access the Items property without actually naming the object.  You can do this the same way you would with a Win32 application under Delphi.

The following code will capture the currently selected string each time it changes in the drop-down (note that, under ASP.NET, this only occurs when some reason exists for a "trip to the server", and the user choosing a new drop-down value is NOT such a reason (at least, not when runat="server" is set)).

This assumes the default naming of DropDownList1 for the object:

procedure TWebForm1.DropDownList1_SelectedIndexChanged(sender: System.Object; e: System.EventArgs);
    sItemString := DropDownList(sender).Items.Item[DropDownList(sender).SelectedIndex].ToString;

(we are simply casting the sender argument as a DropDownList, since sender is the object that caused the event, and it's a DropDownList, but we need to "upcast" from Object in order to access the DropDownList properties). 

This makes this code portable to other DropDownLists, regardless of their naming or scoping.


Share a thought or comment...
Write a Comment...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.

Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P1156A1
Enter key:
KB Post Contributed By Joshua Delahunty:
I am a software engineer with many years professional experience, using everything from 6809 assembly language to C, C++, Delphi, Paradox for Windows, and Borland JBuilder.
Visit Profile

 KB Article #100369 Counter
Since 4/2/2008
Go ahead!   Use Us! Call: 916-726-5675  Or visit our new sales site:

©1995-2021 Prestwood IT Solutions.   [Security & Privacy]