Hello,
I have a Javascript function which will get executed only when I click a
Image Button on my aspx page (code behind - C#).
C# InImgBut on click function -->
{
RegisterStartupScript("FormSubmittedJSCode", "<script>init();</script>"); //
line1
double ax = Convert.ToDouble(ax1.Text); // line2
double ay = Convert.ToDouble(ay1.Text); /line3
}
Part of Javascript -->
function init()
{
function clearObj()
{
if (rect)
rect.parentNode.removeChild(rect);
rect = null;
document.getElementById("InImgBut").click(); // main line javascript
}
function draw(e)
{
if (rect)
{
var currX = (window.event)? event.x: e.clientX;
var currY = (window.event)? event.y: e.clientY;
// make sure not outside the bounds of image
var leftX = getX(MapImage);
var leftY = getY(MapImage);
if (currX < leftX || currY < leftY)
return false;
var sOffset = new Array(2);
sOffset = getScrollOffset();
currX -= (xOffset - sOffset[0]);
currY -= (yOffset - sOffset[1]);
}
}
}
The problem here is when I Click the button, javascript is getting executed.
but also the line2 and line3 are getting executed. I want line2 and line3 to
be executed only after the mainline in javascript function got executed. The
javascript above will draw a rectangle on top of the image. Line 2 and 3
should be executed only when I finished drawing the rectangle.
I tried on
this.InImgBut.Attributes.Add("onClick","<script>in it();</script>"); on page
load and button click event. But somehow I'm not able to achieve the above
mentioned functionality. How can I achieve this?
Any help would be greatly appreciated!
-- Steven