In my code behind, I’m using a constant String and String.Format to create a series of svg elements as such:
const string BoxTemplate = "<rect x=\"{0}\" y=\"{1}\" height=\"{2}\" width=\"{3}\" fill=\"{4}\" stroke=\"#707070\" onmouseover=\"showToolTip()\"/>";
string s = String.Format(BoxTemplate, x, y, h, w, color);
I’m then using a Literal control to render the images.
I’d like to include data or at least a data key in the element for the mouse over or other event to use. I thought about setting the id to the datakey, but there are some cases where more then one image will reference the same data.
What’s the best way to get my javascript function to recognize which element was “moused over” and to access its data/datakey.
You can use the
thisas a parameter to your function. You could also add an additional parameter if you have that at rendering time.This works for me: