ASP.NET equivallent to document.getElementById

F

Ferret Face

Hi, Folks!

Does ASP.NET have an equivallent to JavaScript's getElementById?

I am saving the name of an object in a hidden textbox (as a string obviously) because I cannot use session objects.

Thx.
 
S

sreejith.ram

Are you looking for how to get a control by its ID from code behind?

the code would be

this.FindControl("txtHiddenName")
 
K

Karl Seguin

Just keep in mind that getElementById() will search at any depth from the
current node. FindControl() will only look at the current level, unless you
use the fully quantified id.

for example, if you have a textbox within a user control, and do:

Page.FindControl("myTextBox")

it'll return null.

if you do myUserControl.FindControl("myTextBox") it'll return the textbox.

if you do Page.FindControl("myUserControl_MyTextBox") it'll return the
control (well, that's not what it'll actually be, but you get the idea...)

Karl
 
F

Ferret Face

Woohoo!

That worked.

I ended up having to use:

Dim myTextBox as TextBox =
Page.FindControl("myForm").FindControl("myPanel").FindControl(objName)

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top