So I have visual basic code in a classic asp page where I want to get a javascript error message to display if my code reaches a certain point:
<%
Function parseString(inputString){
'some code
if startPos > 0 Then
'some code
Else
displaymessage
End if
}
'more code
%>
<script type ="text/javascript">
function displaymessage() {
alert("Wrong!");
}
</script>
How do I get the displaymessage function to execute at a specific point in my visual basic code?
You could also do this:
But you have to realise that (as Lee said) vb code runs on the server and only after it is done, its result will be sent to the client and there your js code will run. This means that your vb code will not be stopped by this alert. Moreover, this alert may not even display on the client because just blindly writing this piece of javascript code to the response may not result in a valid document.