424,279 Members | 1,907 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,279 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.