1

I need to work with an ASP page coded in Visual Basic

I was wondering how I could create an error popup with the content:

alert("No such entry exists")

in visual basic. Is there a way to embed javascript code in visual basic or do error pop-ups in visual basic itself?

3
  • Do you mean VB in Classic ASP? if not, whats hosting the VB? Commented Dec 15, 2011 at 14:49
  • So is this an HTML page viewed in Internet Explorer, with VB code in the page as script? Commented Dec 15, 2011 at 14:55
  • The VB code is in <%...%>. It's a collection of asp files with some html and vb content. Commented Dec 15, 2011 at 15:04

2 Answers 2

2

A simple Response.Write should work. Try this:

<% Response.Write("<script type=""text/javascript"">alert('No such entry exists');</script>") %>

It's been way too long since I've done Classic ASP, so you may need to verify that "" is the right way to escape quotes in a VBscript string.

Sign up to request clarification or add additional context in comments.

2 Comments

I should clarify. The Visual Basic is in an asp page already enclosed <%...%>, so I can't put a different set of tags inside it.
If you're already inside code, just leave off the <% %> in my answer above. It should work just fine.
0

An asp page is just a type of html page. Anything you could put in plain html, such as a script block, can also be put in an asp page. Obviously, though, if it's not server-side script, then it shouldn't go inside the <% %> markers.

 <%Option Explicit%>
 <!DOCTYPE ... >
 <html>
 <head>
 --html header stuff goes here, like css declarations--
 <script type...>
 --javascripty (client-side) things go here--
 </script>
 <%
 --vbscript (server-side) stuff goes here, or you can change your
 server settings to use javascript instead--
 %>
 </head>
 <body>
 --more combinations of straight html markup, 
 client-side scripting enclosed in <script> tags, and 
 server-side code enclosed in <% %>--
 </body>
 </html>

Note that you want to minimize the dropping in and out of server-side script, but the point is that you can have as many code blocks as you need.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.