Click here to Skip to main content
15,891,567 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Experts! :)
this is my asp page
on button click I want to call vbscript function but not working
I have tried many results from google search but they didn't worked :(
XML
<html>
<head>
<%
sub TestOnClick()
        response.write "<script>alert(1);</script>"
end sub
%>
</head>
<body>
<form name="form" >
<%
        response.write "<script>alert(1);</script>"
%>
<Input type='button' id='btn' value='click' onclick='<%TestOnClick()%>' />

</form>
</body>
</html>


please help to solve it
Posted
Updated 13-Feb-13 18:52pm
v2

You are writing vbscript inside ASP indicators. Change your <% %> to <script type="text/vbscript"></script> or use classic ASP instead.
 
Share this answer
 
Why can't you try like this...?

JavaScript
<script runat="server">

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Response.Write("hi")

    End Sub
</script>

ASP.NET
<div>
    
        <asp:button id="Button1" runat="server" onclick="Button1_Click" text="Button" xmlns:asp="#unknown" />
    
    </div>

Hope this will help you..
 
Share this answer
 
I got solution from a site,
It's not possible to call server-side method from page e.g. on-click event in core Asp

so, that I have create a page and list there all tasks and then call that page using Javascript XttpPageRequest

Hope, it will help them who are facing same problem.
Happy Coding!
:)
 
Share this answer
 
v2
Comments
Member 12175770 24-Feb-17 6:49am    
Can you please share link or code?
YogitaMS 12-Apr-19 5:01am    
facing same problem.... cam you pls elaborate your solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900