I have a property string OnClientClick and this contains a javascript string supplied by the user of my Ajax server control (this is similar to ImageButton mapping OnClientClick to the actual html tag’s onClick).
My questions are:
- How do I achieve this mapping and cause my tag to output onClick
based on what’s been supplied for OnClientClick? - If my tag is a span element, would onClick trigger when a child
element is clicked (e.g. input type=”image” tag)?
Try adding the attribute
onclickto your server user control.Control.Attributes.Add(“onclick”,”NameOfYourJSfunction or Javascript code here.”)
The click event will bubble up the dom unless you have an event handler between the clicked element and the span element that suppresses propagation