473,473 Members | 1,457 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

javascript not firing

I tried placing the following logic in my page_load event
to handle the client-side jhavascript needed to add the
first 2 textboxes to the total:

<code>
txtMileageBeginning.Attributes.Add("onChange", "ChkMileage
(document.getElementById('" &
txtMileageBeginning.ClientID & "'),
document.getElementById('" & txtEnding.ClientID & "'),
document.getElementById('" & txtTotal.ClientID & "');")

txtEnding.Attributes.Add("onChange", "ChkMileage
(document.getElementById('" &
txtMileageBeginning.ClientID & "'),
document.getElementById('" & txtEnding.ClientID & "'),
document.getElementById('" & txtTotal.ClientID & "');")

Dim sbChkMileage As New StringBuilder
sbChkMileage.Append("<SCRIPT
language='javascript'>")
sbChkMileage.Append("function ChkMileage
(objTextBox1, objTextBox2, objTextBox3) { ")
sbChkMileage.Append("if(objTextBox1.value.length
0 && objTextBox2.value.length > 0 && document.") sbChkMileage.Append("getElementById
(objTextBox3).value == objTextBox1.value +
objTextBox2.value)}")
sbChkMileage.Append("</SCRIPT>")
RegisterStartupScript
("PageStartupScriptChkMileage", sbChkMileage.ToString)
sbChkMileage = Nothing
</code>

When I'm debugging and view the source code, I get the
following in the View Source:
<code>
onChange="ChkMileage(document.getElementById
('txtMileageBeginning'), document.getElementById
('txtEnding'), document.getElementById('txtTotal');

<SCRIPT language='javascript'>function ChkMileage
(objTextBox1, objTextBox2, objTextBox3) { if
(objTextBox1.value.length > 0 && objTextBox2.value.length 0 && document.getElementById(objTextBox3).value ==

objTextBox1.value + objTextBox2.value)}</SCRIPT>
</code>

While also debugging, there was no "running document"???

What am I doing wrong, because the javascript is not
firing after I place values in the first two textboxes???
Nov 18 '05 #1
2 1453
HI,

from MSDN : "This event is fired when the contents are committed and not
while the value is changing. For example, on a text box, <b> this event
is not fired while the user is typing, but rather when the user commits
the change by leaving the text box that has focus. </b> In addition,
this event is executed before the code specified by onblur when the
control is also losing the focus."

HTH

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)52-8888377
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #2

"bill yeager" <an*******@discussions.microsoft.com> wrote in message news:1a*****************************@phx.gbl...
I tried placing the following logic in my page_load event
to handle the client-side jhavascript needed to add the
first 2 textboxes to the total:

<code>
txtMileageBeginning.Attributes.Add("onChange", "ChkMileage
(document.getElementById('" &
txtMileageBeginning.ClientID & "'),
document.getElementById('" & txtEnding.ClientID & "'),
document.getElementById('" & txtTotal.ClientID & "');")


"ClientID" might not be enough: try UniqueID.Replace(":", "$")
The controls in html have longer names than within your code!

Hans Kesting
Nov 18 '05 #3

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

Similar topics

5
by: Mike | last post by:
In my previous post, I wrote: > ... > GOAL: (very simple) Provide a hyperlink which, when clicked, > calls a javascript function which opens a new URL. > ... > PROBLEM: The following code...
4
by: joebob | last post by:
The following script if run in Internet Explorer should display a thumbview of a webpage that you point it to. To test it, replace test.htm with a valid html file. The problem I'm having is that...
14
by: tshad | last post by:
I posted this on the asp.net group, also. I wasn't sure whether this was an asp.net problem or a javascript problem. I have a page that was originally created from a program I found on the net...
5
by: elsenraat_76 | last post by:
Hello! I was wondering if someone could help me out with a problem I'm having? I'm trying to input a javascript value into an anchor tag (from a function), but don't have an event to call the...
6
by: Jim | last post by:
Group, How would I go about firing a JavaScript method from a C# method in the aspx code behind file? It seems as though this could not be done since JavaScript is executed from within the Web...
0
by: Chris Fink | last post by:
My goal is to have an ASP.NET checkbox server tag with it's autopostback set to true, that when clicked will run the checkbox's CheckedChanged event. However, I would like to try to add a...
8
by: simon | last post by:
hello. hopefully another quick newbie question for you.... I have a codebehind function coded to handle the click event of a button. what this function does is insert values from a data grid...
2
by: mrajanikrishna | last post by:
Hi I am designing an application. I have developed an user control for sidebar links(User details, edit details, change password). These are given in LoginView control, LoggedInTemplate. ...
2
by: =?Utf-8?B?QVZM?= | last post by:
i've a webpart which has datarepeater control.. the datarepeater control has some rows along with the delete button.. I want to shown a confirmation pop up before performing delete action..using...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.