467,864 Members | 1,926 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,864 developers. It's quick & easy.

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
  • viewed: 1412
Share:
1 Reply
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 this site, you agree to our Privacy Policy and Terms of Use.