I have a composite server control that contains a div to which I attach a right click event handler in the Render method (simplified for clarity):
protected override void Render(HtmlTextWriter writer)
{
base.Render(writer);
writer.write(@"
<script type=""text/javascript"">
document.getElementById(""myDiv"").onmousedown = function(event)
{
e = FixupMouse(event);
if (e.which == 3)
// Do my stuff
}
</script>
";
}
The server control is placed within an update panel on an aspx page.
After the initial page load all is well but as soon as the updatepanel performs a callback the event handler is lost. I've changed the function to just do an alert to prove it's none of the code in the function.
The server control itself is declared with the following:
public class myBase : CompositeControl, INamingContainer
I really am at a loss as to why this is happening... any clues?
Cheers