471,591 Members | 1,982 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,591 software developers and data experts.

Native .NET Function to Bind to WebControl via ID String???

Is there a function I can use to bind to a web control on an ASP.NET 2.0 page
if I have a string for the ID of the control? I'd like to be able to throw
an ID string at a function and bind a control object to a textbox control
without having to loop through all the controls on the page.

For example (pseudo code), if I have a textbox with id="txtFirstName"...

Dim ctrlControlPlaceHolder as control
ctrlControlPlaceHolder = FindControlbylID("txtFirstName")
ctrlControlPlaceHolder.text = "Chris"

What I'm looking for is the "FindControlbyID(byVal ID as string)" function.
It's my assumption that there's a native function out there to do it. I
could probably write a function that does the control looping, but I'm going
to have a ton of controls on the page so a native function strikes me as much
more efficient and graceful.

Any help on this is greatly appreciated.

v/r

Chris Frohlich
Jun 28 '06 #1
1 1518
Doesn't the Page class have a FindControl method? I seem to remember it has
one, or maybe I am just having a "developer Senior Moment"?
Cheers,
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"ChrisFrohlich" wrote:
Is there a function I can use to bind to a web control on an ASP.NET 2.0 page
if I have a string for the ID of the control? I'd like to be able to throw
an ID string at a function and bind a control object to a textbox control
without having to loop through all the controls on the page.

For example (pseudo code), if I have a textbox with id="txtFirstName"...

Dim ctrlControlPlaceHolder as control
ctrlControlPlaceHolder = FindControlbylID("txtFirstName")
ctrlControlPlaceHolder.text = "Chris"

What I'm looking for is the "FindControlbyID(byVal ID as string)" function.
It's my assumption that there's a native function out there to do it. I
could probably write a function that does the control looping, but I'm going
to have a ton of controls on the page so a native function strikes me as much
more efficient and graceful.

Any help on this is greatly appreciated.

v/r

Chris Frohlich

Jun 29 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

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.