473,320 Members | 2,003 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

ASP.NET equivallent to document.getElementById

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.
Nov 19 '05 #1
3 26843
Are you looking for how to get a control by its ID from code behind?

the code would be

this.FindControl("txtHiddenName")

Nov 19 '05 #2
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

--
MY ASP.Net tutorials
http://www.openmymind.net/
<sr**********@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
Are you looking for how to get a control by its ID from code behind?

the code would be

this.FindControl("txtHiddenName")

Nov 19 '05 #3
Woohoo!

That worked.

I ended up having to use:

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

Thanks.

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:%2****************@TK2MSFTNGP11.phx.gbl...
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

--
MY ASP.Net tutorials
http://www.openmymind.net/
<sr**********@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
Are you looking for how to get a control by its ID from code behind?

the code would be

this.FindControl("txtHiddenName")


Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Gary Mayor | last post by:
Hi, I'm back again. Basically i'm trying to draw a box over an image which is turning out to be a nightmare. The problem i'm getting at the moment is that i'm creating a line with <div which works...
1
by: lawrence | last post by:
This PHP function prints out a bunch of Javascript (as you can see). This is all part of the open source weblog software of PDS (www.publicdomainsoftware.org). We had this javascript stuff...
12
by: lawrence | last post by:
The following function correctly makes everything invisible but then fails to turn the one chosen DIV back to visible. I imagine I'm getting the syntax of the variable wrong? I've tried this with...
4
by: lawrence | last post by:
Can anyone tell me why this code works in Netscape 7.1 but not in IE??? <SCRIPT type='text/javascript'> function makeVisible(nameOfDiv) {...
7
by: PaulB | last post by:
Good Morning everybody, I'm trying to adapt a tutorial script that will handle the behaviour of an "Expanding/Contracting" site-navigation menu. The code that seems to handle the expansion and...
3
by: davidkarlsson74 | last post by:
Error: document.getElementById("folderMenu").cells has no properties File: http://www.volkswagen.se/tillbehor/js/foldermenu.js Rad: 49 The function activates different DIV:s, but doesn't seem to...
1
by: Andre Ranieri | last post by:
Hello, I'm trying to set up an ASP.NET 2.0 form where the user enters values in WebControls.TextBoxes for amount owing, interest and late fees and a JavaScript function totals the three values...
4
by: dr1ft3r | last post by:
Hey guys, I'm building a site for a landscaping business down the street and can't seem to get part of the code functioning correctly. The code fails on line 68 where I make a reference to an...
13
by: RommelTJ | last post by:
Hi, My website (http://www.justiceinmexico.org/indextest.php) looks good in Firefox, but horrible in IE, and I think it's because of an error in the javascript of a free web ticker I got off the...
29
by: Nick | last post by:
I've seen a few frameworks use the following: function $(id) { return document.getElementById(id); } Then to use: $('something').innerHTML = 'blah'; I'm just trying to roll this out to my...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.