Hi,
I'm trying to add a button control to my ListView control dynamically in code behind with some JavaScript functionality added. I have a panel control in my ListView in order to add the button dynamically in the ItemDataBound event.
pnlContent.Controls.Add(new LiteralControl("<button onclick='alert('Hello World!');return false;'>Test Button Code Behind</button>"));
However although the buttons appears once the page has loaded the source code appears as:
<button onclick="alert(" hello="" world!');return="" false;'="">Test Button Code Behind</button>
So the JavaScript is not functional due to the additional ="" being added after each space (not sure why this is happening?). I would really appreciate any help or pointers as to where I'm going wrong?
Many thanks,
Daniel