ASP VBSCRIPT FUNCTION

hari_mani
hari_mani used Ask the Experts™
on
IN AN ASP PROGRAM.. IAM HAVING A BUTTON WHICH HAS AN EVENT ONCLICK TO FUNCTION CALLED "CK()"

NOW WITHIN THE ASP TAGS, WHEN IAM CALLING THE FUNCTION
CK(), IM WRITING TEXT USING RESPONSE.WRITE..

BUT IAM UNABLE TO DO SO
IM GETTING AN ERROR LIKE "TYPE MISMATCH" FOR THE ONCLICK
EVENT.

PLEASE HELP.

MY PROGRAM

<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">

<%
sub ck()
response.Write ("sadfasdf")
end sub
%>
</HEAD>

<BODY>

<P>&nbsp;</P>

<INPUT type="button" id=button1  name=button1 onclick = "ck()" >

</BODY>
</HTML>
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Author

Commented:
I DONT HAVE AN ANSWER
Try using client function. I would use javascript for that instead of client vbscript because client vbscript cannot be run on netscape.


<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">

<script language="JavaScript">
function ck() {
     document.write ("sadfasdf")
}
</script>
</HEAD>

<BODY>

<P>&nbsp;</P>

<INPUT type="button" id=button1  name=button1 onclick = "ck()" >

</BODY>
</HTML>



hongjun

Commented:
The simple "answer" is that you are mixing client side and server side script (although language will still be a potential issue).

The code:

<%
sub ck()
response.write("sadfasdf")
end sub
%>

is executed at the server, and it is never seen by the client.

If you execute your page and view the source code, you will see no reference to this sub.  Ergo, the client (browser) is looking for a client side script to execute, and it generates the error.

A client side javascript (or vbscript) function is your only option.

Tom
Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

This will work the way you want.
still you need some study of ASP.

<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">

<script language=VBScript>
sub ck()
alert ("sadfasdf")
end sub
</script>
</HEAD>

<BODY>

<P>&nbsp;</P>

<INPUT type="button" id=button1  name=button1 onclick = "ck()" >

</BODY>
</HTML>
Expert of the Year 2014
Top Expert 2014

Commented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Accept Answer by puranik_p

Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
GaryC123
EE Cleanup Volunteer
hari_mani,
have you accepted this answer?
if not, I would like to know why its (force?) accepeted against recommendation.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial