Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Constructing a string dynamically

Status
Not open for further replies.

belle9

Programmer
Nov 3, 2004
87
US

I have this in javascript with vb.net/asp.net:

var tabContainer = $get('<%=tab1.ClientID%>');

tab1 is the name of a specific element on my form. i want to make that dynamic, so that it can be passed as a variable to my function. I've tried a bunch of ways with single and double quotes, but no luck.

Any ideas?
Thanks!
 
Anyway - if you want to reference a named element on a named form, you can use:

Code:
document.forms['formName'].elements['elementName']

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Tech Snippets & Info:
 
$get is something jquery or the ms ajax framework script syntax. Basically replacing getElementById(). The <%...%> is the asp.net bit. Are you using jquery or are you running a microsoft asp.net enabled web site?

On first look I don't think you're approaching you're problem the best way! But aside from that:

- Ensure your control 'tab1' has runat="server" attribute
- Ensure you script is within the form tag - or if its in the head section ensure head has the runat="server" attribute

Was this any help?

Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top