473,395 Members | 1,968 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,395 software developers and data experts.

Error using RegisterClientScriptBlock

Hello,

I am trying to create a JavaScript function and am getting the following
error: 'jsFormValidation' is not a member of 'ASP.ciJava_aspx'.

Sub Page_Load(Sender As Object, E As EventArgs)
Dim ctrlValidate As String = tbxSubmitter.ID
Dim strFormValidation As String = _
"<script language='javascript'> function jsFormValidation() {" & _
"alert('Please enter your Name in the |Name| field.');" & _
"document.getElementById('" & ctrlValidate & "').focus();}" & _
"<" & "/script>"

If(Not IsClientScriptBlockRegistered("jsFormValidation"))
RegisterClientScriptBlock("jsFormValidation", strFormValidation)
End If
End Sub
In the form:

<td width="100" align="center">
<asp:ImageButton runat="server"
ImageURL="../../images/art_dbflash_go.jpg"
ImageAlign="Middle"
AlternateText="sckeels"
OnCommand="jsFormValidation(this)"
CommandName="ASPNET"/>
</td>
Nov 18 '05 #1
2 1119
You're trying to use a client-side JavaScript function to handle a
server-side event.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Steven K" <sk****@troop.com> wrote in message
news:eP**************@TK2MSFTNGP11.phx.gbl...
Hello,

I am trying to create a JavaScript function and am getting the following
error: 'jsFormValidation' is not a member of 'ASP.ciJava_aspx'.

Sub Page_Load(Sender As Object, E As EventArgs)
Dim ctrlValidate As String = tbxSubmitter.ID
Dim strFormValidation As String = _
"<script language='javascript'> function jsFormValidation() {" & _
"alert('Please enter your Name in the |Name| field.');" & _
"document.getElementById('" & ctrlValidate & "').focus();}" & _
"<" & "/script>"

If(Not IsClientScriptBlockRegistered("jsFormValidation"))
RegisterClientScriptBlock("jsFormValidation", strFormValidation)
End If
End Sub
In the form:

<td width="100" align="center">
<asp:ImageButton runat="server"
ImageURL="../../images/art_dbflash_go.jpg"
ImageAlign="Middle"
AlternateText="sckeels"
OnCommand="jsFormValidation(this)"
CommandName="ASPNET"/>
</td>

Nov 18 '05 #2
Hi Steven

The reason is that OnCommand is a server-side event. How can you call a client-side javascript function through server-side
Please try add this line
Imagebutton1.Attributes("onclick") = "jsFormValidation();
and remove this line
OnCommand="jsFormValidation(this)

Bin Song, MC

Sub Page_Load(Sender As Object, E As EventArgs
Dim ctrlValidate As String = tbxSubmitter.I
Dim strFormValidation As String =
"<script language='javascript'> function jsFormValidation() {" &
"alert('Please enter your Name in the |Name| field.');" &
"document.getElementById('" & ctrlValidate & "').focus();}" &
"<" & "/script>

If(Not IsClientScriptBlockRegistered("jsFormValidation")
RegisterClientScriptBlock("jsFormValidation", strFormValidation
End I
Imagebutton1.Attributes("onclick") = "jsFormValidation();
End Su
In the form

<td width="100" align="center"><asp:ImageButton runat="server
ImageURL="../../images/art_dbflash_go.jpg
ImageAlign="Middle
AlternateText="sckeels
CommandName="ASPNET"/></td>
Nov 18 '05 #3

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

Similar topics

1
by: Mike | last post by:
When trying to compile (using Visual Web Developer 2005 Express Beta; frameworkv2.0.50215 ) the source code below I get errors (listed below due to the use of ICallBackEventHandler. Ultimately I...
1
by: Mike | last post by:
When trying to compile (using Visual Web Developer 2005 Express Beta; frameworkv2.0.50215 ) the source code below I get errors (listed below due to the use of ICallBackEventHandler. Ultimately I...
2
by: kewl | last post by:
Hi All, We have an ASP.NET 2.0 (C#) intranet application that needs to spawn multiple browsers using RegisterClientScriptBlock. Here's what we got so far: // Go thru each datarow in the...
25
by: premprakashbhati | last post by:
i want to have checkboxes in my gridview ...by checking it ,i can delete the row/rows.... so i have written code and got 2 Errors ...can anyone solve it... Error:1...'gridview.RetrieveItems()': not...
4
by: backen | last post by:
Hi! i cant get this code to work, I get error c2065, undeclared identifier for some reason donīt really know why... this results in error C2146: syntax error : missing ';' before identifier...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.