Friday, 6 September 2013

Javascipt function for drawing on canvas, which is called from aspx page, causes an error

Javascipt function for drawing on canvas, which is called from aspx page,
causes an error

I need to call a javascript function from aspx page (C#). This is shor
function is located in aspx file, and it draws a few figures. The function
is invoked by button press. The parameters of figures are taken as some
indexes from mssql database. The javascript code is invoked by the next
command:
ClientScriptManager cs = Page.ClientScript;
cs.RegisterStartupScript(this.GetType(), "myScript", "<script
language='javascript'>htm("+param+")</script>");
The problem is that if I put javascript function htm in the section of
aspx page, then I get a "htm function is not defined", in case if I put
javascript at the end of the html code, I get error with getting canvas
context (null object), because the canvas hasn't been loaded yet. The
partial solution of the issue is assigning the javascript function to
window.onload, but it is not the solution I need, because the figure must
be drawn ONLY ONCE after button press.

No comments:

Post a Comment