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

Advanced
-Collapse +Expand Prism To/From
To/FromCODEGuides
-Collapse +Expand Prism Study Test
PRESTWOODCERTIFIED
-Collapse +Expand Prism Store
PRESTWOODSTORE

Prestwood eMagazine

April 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 14 years ago on 5/3/2006 and updated 1/20/2009
Take Away:

use of Sender under Delphi for .NET

KB100369

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);
begin
    sItemString := DropDownList(sender).Items.Item[DropDownList(sender).SelectedIndex].ToString;
end;

(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.


Comments

0 Comments.
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 = P147A1
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
4985
Since 4/2/2008
Go ahead!   Use Us! Call: 916-726-5675  Or visit our new sales site: 
www.prestwood.com


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