473,569 Members | 2,438 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting the generated name attribute for use in JavaScript

As most of us probably know, ASP.NET controls do not use an exact copy of a
control's ID for the HTML element's name or id attribute. When generating
JavaScript as part of a control or event, we need to have a way to reference
the HTML elements. The only way I have found to reference the HTML elements
in my generated Javascript is the following:

"document.getEl ementById('" & Me.ctrl.ClientI D & "')"

However, this seems like a lot of extra code for each element. Why do the
controls have a ClientID property but not a ClientName property? If there
were a ClientName property, wouldn't it make the code a lot less complicated
and shorten the amount of JavaScript that had to be included with each
control? Or is this just one of those Microsoft things where they are trying
to get people to use the id attribute rather than the name attribute?
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/
Nov 18 '06 #1
1 1065
"Nathan Sokalski" <nj********@hot mail.comwrote in
news:ec******** ******@TK2MSFTN GP03.phx.gbl:
Why do the
controls have a ClientID property but not a ClientName property? If
there were a ClientName property, wouldn't it make the code a lot less
complicated and shorten the amount of JavaScript that had to be
included with each control? Or is this just one of those Microsoft
things where they are trying to get people to use the id attribute
rather than the name attribute?
You can potentially have two objects using the same ClientName - i.e.:

Form
+MyLabel
+MyUserControl
+MyLabel

Thus the Form can have a MyLabel and a MyUserControl MyLabel... so if you
were to refer to MyLabel, which label is it? :-)

But in anycase, you *could* refer to objects by name ... if you know the
exact layout of the page. If you take a close look at the element IDs,
they're generated the same each time (provided the control nesting does not
change).
Nov 18 '06 #2

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

Similar topics

0
1354
by: Nathan Ernst | last post by:
I have a pretty simple XSD schema: ******************************************** * XSD SCHEMA ******************************************** <?xml version="1.0" encoding="utf-8" ?> <xs:schema id="PageHitStatistics" targetNamespace="urn:PageHitStatistics" elementFormDefault="qualified" xmlns="urn:PageHitStatistics"
1
1784
by: Wayne Lian via .NET 247 | last post by:
Hi all, Just wonder anyone have encountered this problem before?I tried using XMLSPY debugger and I can get the correct outputfor my XSLT transformation, however in .net, aftertransformation the attributes I put inside xsl:element tagcannot be generated. Part of the XML data: <?xml version="1.0" encoding="utf-8"?> <receipients> <receipient>...
0
3016
by: keith bannister via .NET 247 | last post by:
(Type your message here) -------------------------------- From: keith bannister Hi, I'm new to .net (as of last week) but here goes. I want to serialize/deserialize a file the conforms to an XML schema (xsd).
5
7273
by: Keith Bannister | last post by:
I'm new to .net so here goes. I'm tying to deserialize a class that is associated with an XML schema. I created the C# class with xsd.exe as below: xsd.exe /c /n:somenamespace properties.xsd this creates properties.cs
5
2155
by: Don | last post by:
Hi: I have created an xsd from my xml document. I pop this xsd in the following directory: C:\program files\Microsoft Visual Studio .NET 2003\Common7\Packages\schemas\xml. That give me intellisense when I specify the name space. But leaving hte namespace in messes up my transforms. Is there any way to get this intellisense functionality...
2
3474
by: Nathan Sokalski | last post by:
As most of us probably know, ASP.NET controls do not use an exact copy of a control's ID for the HTML element's name or id attribute. When generating JavaScript as part of a control or event, we need to have a way to reference the HTML elements. The only way I have found to reference the HTML elements in my generated Javascript is the...
8
7035
by: Les Caudle | last post by:
Using this command line to run XSD.exe xsd /c /o:outputDir input.xsd /f on the following XSD <?xml version="1.0"?> <schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:dino="http://example.com/test" targetNamespace="http://example.com/test" elementFormDefault="qualified">
1
2605
by: Chris White | last post by:
Here's my XML <?xml version="1.0" encoding="UTF-8"?> <results> <status code="ok"/> <report-bulk-users> <row principal-id="23859115" type="user"> <login>muser@domain.com</login> <name>My User</name> <email>myuser@domain.com</email> <manager>manager@domain.com</manager>
1
2316
by: Ben Brown | last post by:
I'm having some problems.. I have some javascript generated input elements with dynamic names and values. ex: <input name = "t1Name" .../> <input name = "t2Name" .../> ..... <input name = "tnName".../>
0
7703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7926
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8138
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7679
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7983
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6287
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3657
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1228
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.