473,322 Members | 1,409 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Small Problem in calling Javascript fucntion

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
Nov 16 '05 #1
1 2172
Your problem arises because lines 2 and 3 are server side code. There fore
although your init() script is registered to run it wont actually fire until
the page reaches the client. Well after lines 2 and 3 are executed.

MattC

"Steven" <counterball_20122@_hotmail.com> wrote in message
news:Ov**************@TK2MSFTNGP09.phx.gbl...
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

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Yvan J. Gagnon | last post by:
I am currenly developing a web site using Macromedia fireworks, and am trying to figure out a way (through hand-coding) of attaching a javascript function (onClick="doit=false") to each of the...
5
by: wylbur37 | last post by:
How do you find out what version of JavaScript your browser supports? Is there a JavaScript function that will tell you? __________________________________ Do you Yahoo!? Find out what made...
13
by: RainBow | last post by:
Hi everyone, (Very Sorry, if this is the wrong group in which I am posting this query). Code snippet: //C library typedef int (*PFunc)(int* aArg); void call_c_foo(PFunc aPtrtoFunc) {
5
by: DotNetJunkies User | last post by:
1. i want to populate checkboxlist using javascript only at client side ....how can i do this..by populate word i mean that checkboxes should be checked or unchecked on some condition basis.......
1
by: mailing | last post by:
Hello, I am hoping that someone can point me in the right direction. I have 4 frames to my site. Two Rows, Two Columns. |--------------------------------|-------------------------| | ...
6
by: simon | last post by:
hello, what code would i use to kick off a javascript script after i had registered it? If (Not Page.IsClientScriptBlockRegistered("jsScript")) Then Page.RegisterClientScriptBlock("jsScript",...
9
by: balakrishnan.dinesh | last post by:
hi frnds, Is there any function in PHP like setTimeout with same functionallity in javascript .. Thing is, In php we have a function call settimeout for socket , But i need the same...
3
by: shyamal123 | last post by:
I am write a function in javascript ie function rowcolor(obj) { obj.parentelement.parentelement.style.backgroundcolor='yellow' ; } when i run the appln the error is occure ie the...
1
by: skanemupp | last post by:
i use this code to profile. however for small standard functions it just says 0 seconds. so one solution is to run the function a very big number of times(how big?). but the bottom code doesnt...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.