Wednesday, July 21, 2010

Edit dynamic control by javascript

So you want to change the properties of a control, such as button "btnPost".

Seems rufly easy to accomplish, unless SharePoint, DotNetNuke or other environment decides to change the ID property of the control, adding internal IDs.

Like this:

So how do you change, say, the display option of the control, to make it visible or hidden?

The trick is to make a function that looks for the control, given a regular expression.

btnGen.Attributes.Add("onclick", "'none';var re = new RegExp('btnPost', 'g');var elems = document.getElementsByTagName('*'), i = 0, el;while (el = elems[i++]){if ({document.getElementById('';location.href='" + url + "';}}"); //hide button

I must say, creadits to make this possible go to Kor's postings on, where we can find the complete function.

No comments:

Post a Comment