Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / December 2007

Tip: Looking for answers? Try searching our database.

Control Handler

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
shapper - 19 Dec 2007 01:57 GMT
Hello,

I am adding an undefined number of Text Boxes to page.

I say undefined because the number of Text Boxes added is defined by a
property of my custom control.

All Text Boxes have the same properties values less two.

I would like to use one function to handle the Init event of all these
TextBoxes and pass to the function those two different properties
values for each Text Box.

Is this possible? And is this the right way to do it?

Remember that I am doing it this way because the number of TextBoxes
is "undefined"

Thanks,

Miguel
zzzxtreme@gmail.com - 19 Dec 2007 03:57 GMT
u can loop inner controls of your custom control (assuming textboxes
is direct children of the control)

let's say you your custom control is X

to loop, u just do

if X.HasControl
For Each C as Control in X.Controls
if Typeof C is TextBox then
  do something
end if
Next

for your other questions on "pass functions" "two less", i don't get
it

> Hello,
>
[quoted text clipped - 17 lines]
>
> Miguel
Andrew - 19 Dec 2007 05:09 GMT
Hi Miguel,

you can get each textbox to call the same function as follows:

       <asp:TextBox OnInit="TextBoxInit" runat="server" ID="txt1" />
       <asp:TextBox OnInit="TextBoxInit" runat="server" ID="txt2" />
       <asp:TextBox OnInit="TextBoxInit" runat="server" ID="txt3" />

Codebehind:

   protected void TextBoxInit(object sender, EventArgs e)
   {
       TextBox txtSender = sender as TextBox;
   }

From there you can use txtSender to get the 2 control-specific properties
you're after.

Best Regards,
Andrew

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.