• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1204
  • Last Modified:

HTML5 show querystrings and if else statements

I'm moving away from ASP pages and going to HTML5 pages.  I alway put these 3 lines of code first in my ASP pages:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">


Now in HTML5 looks like this, one single line:
<!doctype html>


When using vbscript in my html code I used to do something like this below to show passed variables and do if else statements.  How do I get my vbscript to work on my HTML5 page or what alternative do I have?

<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td>
   Album: <%=Request.QueryString("p_heading")%>

   <% If Request.QueryString("p_gallery") = "01" Then %>
      <li><img src="test1.gif" /></li>
      <li><img src="test2.gif" /></li>
   <% Else %>
      <li><img src="test1.gif" /></li>
      <li><img src="test2.gif" /></li>
   <% End If %>
</td>
</tr>
</table>



Sample code or link to samples needed.

Regards,
Torrey
0
Torrey Bates
Asked:
Torrey Bates
  • 8
  • 5
  • 4
1 Solution
 
Dave BaldwinFixer of ProblemsCommented:
You still need <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> at the top of the page to tell the server what you are doing.
0
 
Dave BaldwinFixer of ProblemsCommented:
This page http://www.w3schools.com/asp/default.asp does not show the VBSCRIPT declaration but you may need it anyway to set the 'codepage'.
0
 
Torrey BatesPreidentAuthor Commented:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!doctype html>

When I do that the <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> and view in a browser it literally prints it.

Regards,
Torrey
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
Scott Fell, EE MVEDeveloperCommented:
Your asp code will worth with HTML5, HTML4 or XHTML.    The HTML 5 version is below.  If you have not used Classic ASP in a while and this is a new server, are you sure Classic ASP is turned on?  
http://www.iis.net/learn/application-frameworks/running-classic-asp-applications-on-iis-7-and-iis-8/classic-asp-not-installed-by-default-on-iis


<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Test</title>
</head>
<body>
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td>
   Album: <%=Request.QueryString("p_heading")%>

   <% If Request.QueryString("p_gallery") = "01" Then %>
      <li><img src="test1.gif" /></li>
      <li><img src="test2.gif" /></li>
   <% Else %>
      <li><img src="test1.gif" /></li>
      <li><img src="test2.gif" /></li>
   <% End If %>
</td>
</tr>
</table> 
</body>
</html>

Open in new window

0
 
Torrey BatesPreidentAuthor Commented:
Scott,

Double checked the link you provided and my classic ASP is installed on my local test and host Servers.

If I take your code sample and view in IE, Google Chrome, or Safari - it completely bypasses the vbscript code and prints everything in the <% %> on the web page, the actually code.

If I rename the code sample file from .html to .asp then it works BUT I need to keep my files .html

Regards,
Torrey
0
 
Scott Fell, EE MVEDeveloperCommented:
Are you sure your local webserver is running?    You can run local.html pages with or without the webserver running.  

Are you sure you are in the localhost path?  If you create a simply file called "hello.html" and put any text in the file, save it.  Then http://localhost/hello.html can you view the file?  Same with asp, you have to surf to it http://localhost/Test.asp 

Do you need to add a port to your localhost url?  http://locahost:1234/test.asp
0
 
Torrey BatesPreidentAuthor Commented:
Scott,

Yes - local webserver running.

If I stop the local testing webserver then I get page cannot be displayed when trying to view in browser any html or asp pages that I'm testing with the http://localhost/{page name}.

Also using the "localhost" in the path.  All other html pages work fine this site.  Just the one trying to use vbcsript doesn't process it unless I rename the file from .html to .asp which I want to get away from ASP pages.  I get the same results on the live paid hosting company Server.

Regards,
Torrey
0
 
Scott Fell, EE MVEDeveloperCommented:
OHHH, I understand now.  You want to use asp code inside of a .html page.
0
 
Torrey BatesPreidentAuthor Commented:
Scott,

Yes - since I'm moving from .asp pages to .html pages I need a way to simply show querystring variables or do a if/else/then statement.

Knowing vbscript is the default language in active server pages can vbscript be used on HTML5 pages somehow?  If not, how do people coding in HTML5 handle these tasks?  I can't be the only one wanting to show querystring variables or want to do if/else/then statements.

Regards,
Torrey
0
 
Scott Fell, EE MVEDeveloperCommented:
See if this works.

I have tried a few things on my local machine and no luck but trying this one now.

http://www.experts-exchange.com/Software/Server_Software/Web_Servers/Q_27531603.html#a37418478
0
 
Scott Fell, EE MVEDeveloperCommented:
You can  have html5 in your .asp page.  Remember that vbscript runs on the server.  

If you have the following code below, when you run the page and view source, all you see is html 5.  
First, all the asp/vb is run on the server.  
Next, any html generated by asp/vb along with the page html is rendered in the browser at the same time.
Finally, any javascript is run.
When you view source, it looks like it is all at once because it happens so fast. The end result is an html5 page.
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Test</title>
</head>
<body>
<%
theHTML = "<h1>Hello World</h1>
theHTML=theHTML&"<p>This runs on the server</p>

%>
<p>I am run locally</p>
<p id="test"></p>
<script> 
var p = document.getElementById("test");
p.appendChild(document.createTextNode("Some random text."));
 </script>
</body>
</html>

Open in new window

0
 
Scott Fell, EE MVEDeveloperCommented:
>Moving away from asp.  

What you are doing is not moving away from asp.  You are just allowing asp to use the html extension.
0
 
Scott Fell, EE MVEDeveloperCommented:
I tested that solution and it worked.
0
 
Dave BaldwinFixer of ProblemsCommented:
If you are using VBScript in your pages, you are virtually by definition using ASP (Active Server Pages).  Running pages with a *.html extension thru the ASP interpreter does not change that.  ASP and HTML are simply two different things that can work together.  It does not matter which version of HTML you are generating.
0
 
Torrey BatesPreidentAuthor Commented:
Scott,

Like I said in initial post,  "I'm moving away from ASP pages and going to HTML5 pages."

Others have to be doing what I want to do somehow without keeping, making or tricking anything to make an HTML page think or run like it's an ASP page.  One day I will run into a host that doesn't support classic ASP and I'm not going to deal with that.

Regards,
Torrey
0
 
Dave BaldwinFixer of ProblemsCommented:
If you run into a host that does not support Classic ASP, your VBscript will not run at all.  As long as you are using VBscript in your pages, you are Not moving away from Classic ASP.  Note that if you move to ASP.NET, the newer version, the file extension will be '*.aspx', not '*.html'.  The important point is that you are using server side language.  For 'plain' HTML5, you can't use any server side language.
0
 
Scott Fell, EE MVEDeveloperCommented:
>Like I said in initial post,  "I'm moving away from ASP pages and going to HTML5 pages."

You may have missed my previous comment http:#a39985120 and Dave reiterated very nicely http:#a39986549 

Currently Classic ASP is supported by windows server 2012.  The end of life is scheduled for 2023 http://support.microsoft.com/lifecycle/search/default.aspx?sort=PN&alpha=Windows+Server&Filter=FilterNO

Using HTML5 or XHTML as I explained has little to do with what serverside language you use.  You can move away from HTML4 to HTML5, but using asp and vbscript will have little to do with that as I explained because the code generated is on the server, then sent to the browser along with the html after which any js is run.

If your real concern is a webhost not supporting asp in the future, I suggest learning PHP.  PHP will resemble classic asp more than .NET.   You can still use MS SQL Server with PHP as well as MySQL and  20 other databases http://www.php.net/manual/en/refs.database.vendors.php  http://www.codecademy.com/learn
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 8
  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now