473,385 Members | 2,269 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,385 software developers and data experts.

Help - Registered Javascript not executing

Hi,
On my Webform my ASP:Button does not execute the Javascript code which is
'added' to it on the page load, and I'm trying to figure out why. Please
take a look at my code and the error message and see if there's anything
obvious here:

'------ Here's where the javascript is registered and added to the ASP:Button:

Sub Page_Load()
Call setupClientScript()
If Not IsPostBack Then
btnUpdate.Attributes.Add("onclick", "return ConfirmUpdate();")
End if
End sub

Private Sub setupClientScript()
Dim js As String
js = "<script language=JavaScript> " & _
"Function ConfirmUpdate() " & _
"{ " & _
"return confirm('xxxx?'); " & _
"} " & _
"</script>"

'Register the script
If (Not IsClientScriptBlockRegistered("ConfirmUpdate")) Then
RegisterClientScriptBlock("ConfirmUpdate", js)
End If
End Sub

'------ Here's what I see when I view the source code when the page loads:
<form......
<script language=JavaScript> Function ConfirmUpdate() { return
confirm('xxxx?'); } </script>
.......
<TD vAlign="top" align="left">
<input type="submit" name="btnUpdate" value="Save Changes" onclick="return
ConfirmUpdate();if (typeof(Page_ClientValidate) == 'function')
Page_ClientValidate(); " language="javascript" id="btnUpdate" />

</TD>
......</form>

'------ And here's the error I see when I click on the little yellow
exclamation mark in the bottom left corner of the browser when I click on the
button:

Line: 20
Char: 11
Error: Expected ';'
Code: 0

So, I get this error and I do not get the pop-up confirmation window. Does
anybody recognize this error? Any help is appreciated.

Thanks,
John
Nov 19 '05 #1
2 1520
javascript is case sensitive. "function" needs to be lowercase, and you
should use "window.confirm()" to be browser friendly.

-- bruce (sqlwork.com)
"John Walker" <Jo********@discussions.microsoft.com> wrote in message
news:E0**********************************@microsof t.com...
Hi,
On my Webform my ASP:Button does not execute the Javascript code which is
'added' to it on the page load, and I'm trying to figure out why. Please
take a look at my code and the error message and see if there's anything
obvious here:

'------ Here's where the javascript is registered and added to the
ASP:Button:

Sub Page_Load()
Call setupClientScript()
If Not IsPostBack Then
btnUpdate.Attributes.Add("onclick", "return ConfirmUpdate();")
End if
End sub

Private Sub setupClientScript()
Dim js As String
js = "<script language=JavaScript> " & _
"Function ConfirmUpdate() " & _
"{ " & _
"return confirm('xxxx?'); " & _
"} " & _
"</script>"

'Register the script
If (Not IsClientScriptBlockRegistered("ConfirmUpdate")) Then
RegisterClientScriptBlock("ConfirmUpdate", js)
End If
End Sub

'------ Here's what I see when I view the source code when the page loads:
<form......
<script language=JavaScript> Function ConfirmUpdate() { return
confirm('xxxx?'); } </script>
......
<TD vAlign="top" align="left">
<input type="submit" name="btnUpdate" value="Save Changes" onclick="return
ConfirmUpdate();if (typeof(Page_ClientValidate) == 'function')
Page_ClientValidate(); " language="javascript" id="btnUpdate" />

</TD>
.....</form>

'------ And here's the error I see when I click on the little yellow
exclamation mark in the bottom left corner of the browser when I click on
the
button:

Line: 20
Char: 11
Error: Expected ';'
Code: 0

So, I get this error and I do not get the pop-up confirmation window.
Does
anybody recognize this error? Any help is appreciated.

Thanks,
John

Nov 19 '05 #2
Bruce,
Thanks! Changing the case fixed the problem. But I ran into one more
issue; when I try to "Attribute.Add" this same function to a Datagrid
Checkbox, it puts it in the <span> section (which I see when I "view
source"), and it doesn't fire the function when the check box is changed.
Here's the html, do you see anything wrong here:

<span class="CssReportCell" OnCheckedChanged="SetChangeFlag();"><input
id="dgrdTRFP_dgrdReport__ctl2_chkDispatched" type="checkbox"
name="dgrdTRFP:dgrdReport:_ctl2:chkDispatched" checked="checked" /></span>

Thanks again!

"Bruce Barker" wrote:
javascript is case sensitive. "function" needs to be lowercase, and you
should use "window.confirm()" to be browser friendly.

-- bruce (sqlwork.com)
"John Walker" <Jo********@discussions.microsoft.com> wrote in message
news:E0**********************************@microsof t.com...
Hi,
On my Webform my ASP:Button does not execute the Javascript code which is
'added' to it on the page load, and I'm trying to figure out why. Please
take a look at my code and the error message and see if there's anything
obvious here:

'------ Here's where the javascript is registered and added to the
ASP:Button:

Sub Page_Load()
Call setupClientScript()
If Not IsPostBack Then
btnUpdate.Attributes.Add("onclick", "return ConfirmUpdate();")
End if
End sub

Private Sub setupClientScript()
Dim js As String
js = "<script language=JavaScript> " & _
"Function ConfirmUpdate() " & _
"{ " & _
"return confirm('xxxx?'); " & _
"} " & _
"</script>"

'Register the script
If (Not IsClientScriptBlockRegistered("ConfirmUpdate")) Then
RegisterClientScriptBlock("ConfirmUpdate", js)
End If
End Sub

'------ Here's what I see when I view the source code when the page loads:
<form......
<script language=JavaScript> Function ConfirmUpdate() { return
confirm('xxxx?'); } </script>
......
<TD vAlign="top" align="left">
<input type="submit" name="btnUpdate" value="Save Changes" onclick="return
ConfirmUpdate();if (typeof(Page_ClientValidate) == 'function')
Page_ClientValidate(); " language="javascript" id="btnUpdate" />

</TD>
.....</form>

'------ And here's the error I see when I click on the little yellow
exclamation mark in the bottom left corner of the browser when I click on
the
button:

Line: 20
Char: 11
Error: Expected ';'
Code: 0

So, I get this error and I do not get the pop-up confirmation window.
Does
anybody recognize this error? Any help is appreciated.

Thanks,
John


Nov 19 '05 #3

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

Similar topics

1
by: Phre2d | last post by:
We are attempting to move a large development project into the .NET age over time. We have a large number of ATL-based COM objects in this project. Following the "Journal Poster" example provided...
15
by: Jay | last post by:
I have a multi threaded VB.NET application (4 threads) that I use to send text messages to many, many employees via system.timer at a 5 second interval. Basically, I look in a SQL table (queue) to...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
8
by: Richard Maher | last post by:
Hi, I am in a mouseup event for button A and I'd like to disable=false button B before starting some work. Is there anyway that an event for button B can then fire before my event processing for...
5
by: shanti | last post by:
hai, i have developed a c-code to push integers into a stack (an array). in the program there are three inputs which has to be given through keyboard. the inputs are "choice", "option","S_R_NO"...
8
by: Pratik Patel | last post by:
Hello, I used innerHTML to assign HTML content. but in my HTML page content have also some javascript function and it will run when page load. bu when HTML code assgin thru innerHTML then this...
15
by: rage3324 | last post by:
I am posting html onto my main page between div tags using xmlhttprequest and innerhtml. The html I am posting has javascript inside which I am executing using the eval() function. However, the...
1
by: Cartoper | last post by:
I am trying to deploy a .Net 1.1 project using the VS2003 setup program. I need one assembly to be registered as a COM object via regasm. How does one go about doing that in the VS2003 setup...
5
by: dm3281 | last post by:
I'm really starting to hate writing services -- or trying to, anyway. Why do I need to rename my project to the service name? Why do I need to set the "ServiceName" property to my service name?...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.