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