Re: WebControl.Attributes.Add and custom attributes

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



you are confusing attributes with javascript properties. some html attributes are used to set properties. take the following html

<input Name="c1" id="c1" type="hidden" Value="value1" myattribute="foo">

when the browser parses the input node, it set properties for name, id, type and value attributes which have the same name (but in lowercase).

this you can reference the value by:

document.getElementById('c1').value

notice you have to use "value", even though it was specified "Value". in javascript you can also add a dynamic property:

document.getElementById('c1').Value = "myValue";

now the input has a "Value" and "value" property.

because the input is a dom object, it also has additional dom properties. attributes are accessed with dom methods and are not properties. to access an attribute:

document.getElementById('c1').getAttribute('myattribute');

to create one:

document.getElementById('c1').getAttribute('Value')='attvalue';

now the input has a 'Value' attribute distinct from the 'Value' property.


note: the browser only post back name/value pairs for form elements, so any attribute changes are not seen by the server.

-- bruce (sqlwork.com)










P4trykx wrote:
Hello
I'm want to add some custom attributes to WebControls using
WebControl.Attributes.Add("abc","234");
So the html output will look like this,
<input type="hidden" abc="123" /> etc.

I know that I need to modify .dtd file and tell the browser that abc i
legal attribute.

But I have another problem, I can't change the abc attribute using
javascript, the change is invisible in code behind :-(. (in js it's
visible)

C#
someTextBox.Attrbites.Add("abc","1");

JS
document.GetElementById("someTextBox").abc = "0" ;

here goes the psotabck on server

C#
someTextBox.Attrbites["abc"] == "1"


Patryk

.



Relevant Pages

  • Re: Obstacles for Tcl/Tk commercial application development ?
    ... printing tabular-report type data? ... is that most modern desktops will have a web browser available. ... - Generate HTML using the tcllib HTML package. ... Javascript like the following: ...
    (comp.lang.tcl)
  • Re: JS, DOM and tr... IE problems!
    ... I've got a problem with javascript and DOM. ... Capitalisation is often used in HTML markup, ... If you post what your browser is actually getting (e.g. using view ...
    (comp.lang.javascript)
  • Re: No TABLES in html. No hacks in CSS. Any layout possible, crossbrowser. Try it.
    ... content, clean html, separating defining visual aspects from defining ... them in the browser as they would be if the author had coded them ... And writing semantic html is writing html ... By switching to Javascript to lay out your page, ...
    (comp.infosystems.www.authoring.html)
  • Re: javascript > variable reset help!
    ... and the is being passed to the javascript as requested. ... all done via HTML on the client-side. ... that the browser won't recognize as HTML and will therefore ignore. ... > doesn't reset for new input unless you clear your browser settings. ...
    (alt.html)
  • comp.lang.javascript FAQ - META 2009-03-04
    ... The official Big 8 Usenet newsgroup dealing with javascript is ... relates to javascript in a web browser. ... Questions that are specific to Microsoft's JScript may also ... This FAQ provides URLs to further information about ECMAScript ...
    (comp.lang.javascript)