Friday, January 18, 2008

ClientID value

Asp.Net form items that are run server side get their ids changed when they are rendered in the HTML sent to the client. Not a huge deal, but a bit of a pain to reference in javascript and keep everything in check.

Then I stumbled across the "ClientID" property on server controls, which is a very convenient way to reference their resulting clientID value. For example:

aspnetForm.<%=myTextBox.ClientID %>.value = "the new value";

No comments: