Ask a Question related to ASP.NET Building Controls, Design and Development.
-
Nathan Sokalski #1
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.getElementById('" & Me.ctrl.ClientID & "')"
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
[email]njsokalski@hotmail.com[/email]
[url]http://www.nathansokalski.com/[/url]
Nathan Sokalski Guest
-
unable to execute a javascript in a dynamically generated HTML
Hi, I have a dynamically generated HTML code rendered on a browser instance created though code (AxSHDocVw.AxWebBrowser instance) . I have... -
Javascript Generated Select box
I hope someone can see something in this code that neither I nor my fellow developers are perceiving. The code below generates a list of states... -
embeding Javascript src attribute in User control
I have a System.Web.UI.UserControl as custom control. I have a javascript block for user control. The problem is I want to bring src attribute from... -
Amrita and programmatically-generated JavaScript
I'm still in the middle of porting my PHP-based web thinking into a ruby frame of mind. I'm looking into amrita for my templating engine but I am... -
[Serializable] attribute on generated classes
Hi, I'm passing a complex type, which I have defined, via a web service method....in the client generated reference.cs I want the class to be... -
Spam Catcher #2
Re: Getting the generated name attribute for use in JavaScript
"Nathan Sokalski" <njsokalski@hotmail.com> wrote in
news:ecZHJ8qCHHA.4740@TK2MSFTNGP03.phx.gbl:
You can potentially have two objects using the same ClientName - i.e.:> 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?
>
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).
Spam Catcher Guest



Reply With Quote

