Click here to Skip to main content
15,888,169 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi frds,

I got big trouble in creating svg polygon dynamically.
Here is my javascript code

C#
<script type="text/javascript">

        var svgNS = "http://www.w3.org/2000/svg";
                function CreateHexagon(xx,yy) {
        var x1 = parseInt(xx), y1 = parseInt(yy)
            var myHexagon = document.createElementNS(svgNS, "polygon");
            myHexagon.setAttributeNS(null, "id", "Hexagon");
            myHexagon.setAttributeNS(null, "points", ""((x1 / 4), 0)((3 * x1) / 4, 0)((x1), (y1 / 2))((3 * x1) / 4, y1)((x1 / 4), y)(0, (y1 / 2))); ""
           // myHexagon.setAttributeNS(null, "points", "50,5   100,5  125,30  125,80 100,105 50,105  25,80  25, 30");
            myHexagon.setAttributeNS(null, "fill", "blue");
            myHexagon.setAttributeNS(null, "stroke", "none");
            document.getElementById('mySVG').appendChild(myHexagon);
        }

    </script>


and this is my code behind

ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "tn1", "<script>CreateHexagon(978,183)</script>", false);

please please solve my trouble.This is an error


JavaScript runtime error: Function expected
Posted
Comments
Dhaval Patel 6-Nov-13 8:26am    
Make sure that your function loads before you call it from code behind.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900