Compilation error in Include file - asp.net

I'm working on my company's website. The task I have is to display the user's name and ID at the top of each page of the website, once the user logs in. However, the top section of each page is controlled by an Include file, Header.inc. I'm getting the examinee's name and ID through some VB/Javascript. The problem is that an aspx page inserts the Include file before it runs the VB/javascript (if you're not familiar with what I'm talking about, see here, towards the bottom of the page: http://www.w3schools.com/asp/asp_incfiles.asp). Basically, the code in the Include file references the variables for the name and ID before the script declares them. The only solution I currently know would be to get rid of the Include file and insert that html in each page, but I'd like to avoid that. Any ideas how I can get around this problem? I read that Include files are old school and I should use Master files instead, but I really don't know how to do that. I'm pretty new at aspx development and working on modifying an existing website I did not create. Please be as specific as possible in your answers.
Thanks in advance,
Dan
Here's the error I get on the webpage:
(FYI the webpage is index.aspx)
Server Error in '/' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: BC30451: Name 'strName' is not declared.
Source Error:
Line 11: </br>
Line 12: </br>
Line 13: <a><%=strName%> </a>
Line 14: </br>
Line 15: <a>Examinee ID# <%=strNBCEID%> </a>
Here's the code for the Include file:
(the include file is Header.inc)
<!-- Start Header -->
<div class="container-header">
<div class="pageheader">
<a href="/home.aspx" > (text removed) Home</a> |
<a href="(link removed)" >(text removed)</a> |
<a href="/logout.aspx" >Logout</a> |
<a href="/contact.aspx" >Contact Us</a>
</br>
</br>
</br>
</br>
<a><%=strName%> </a>
</br>
<a>Examinee ID# <%=strNBCEID%> </a>
</div>
<div class="header">
<br />
<span id="menuiconspan">
<a onclick="showMenu()">
<img src="/images/menubutton.png" />
</a>
</span>
<span id="headermenulogospan-lg" >
<img src="/images/logow.png" height="73px" width="187.5" />
</span>
<span id="headermenulogospan-sm">
<img src="/images/logow.png" height="49px" width="125" />
</span>
</div>
</div>
<!-- End Header -->
Here's some of the code (the section I deemed relevant) of my aspx file:
(webpage name is index.aspx, just for reference)
<%# Page Language="VB" Inherits="MySecurity" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Dim strName As String
Dim strAddress As String
Dim strPhone As String
Dim strEmailProc as String
dim strNBCEID as String
Protected Sub Page_Load()
Dim dvUser As Data.DataView
SecurityCheck()
sqlUser.SelectParameters("ExamineeNo").DefaultValue = Session("ExamineeNo")
dvUser = sqlUser.Select(DataSourceSelectArguments.Empty)
strName = dvUser.Table.Rows(0)("FirstName").ToString & " " & dvUser.Table.Rows(0)("LastName").ToString & " " & dvUser.Table.Rows(0)("Suffix").ToString
If dvUser.Table.Rows(0)("CurrentCountry").ToString = "1" Then
strAddress = dvUser.Table.Rows(0)("CurrentStreet").ToString & "<br />" & dvUser.Table.Rows(0)("CurrentCity").ToString & ", " & dvUser.Table.Rows(0)("CurrentState").ToString & " " & dvUser.Table.Rows(0)("CurrentZip").ToString
Else
strAddress = dvUser.Table.Rows(0)("CurrentStreet").ToString & "<br />" & dvUser.Table.Rows(0)("CurrentCity").ToString & " " & ZipFormat(dvUser.Table.Rows(0)("CurrentCountry").ToString, dvUser.Table.Rows(0)("CurrentZip").ToString) & "<br/>" & GetTableValueString("lkpCountry", "CountryName", "[CountryID]=" & dvUser.Table.Rows(0)("CurrentCountry").ToString)
End If
If dvUser.Table.Rows(0)("CurrentPhone").ToString <> "" Then
strPhone = Left(dvUser.Table.Rows(0)("CurrentPhone").ToString, 3) & "-" & Mid(dvUser.Table.Rows(0)("CurrentPhone").ToString, 4, 3) & "-" & Right(dvUser.Table.Rows(0)("CurrentPhone").ToString, 4)
Else
strPhone = ""
End If
strEmailProc = dvUser.Table.Rows(0)("Email").ToString
strNBCEID = dvUser.Table.Rows(0)("NBCEID").ToString
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>(text removed)</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="text/javascript" src="../js/template.js"></script>
<link href="../css/template.css" rel="stylesheet" />
<script language="javascript" type="text/javascript">
function PageLoad() {
}
</script>
<script type="text/javascript" src="../js/jquery-1.js"></script>
<script type="text/javascript" src="../js/jquery.js"></script>
</head>
<body onload="PageLoad()" onresize="resetMenu();">
<form id="form1" runat="server" requiressl="true">
<div>
<!-- #include virtual="~/include/sidenav.inc" -->
<!-- #include virtual="~/include/header.inc" -->
<div class="container">
<!-- #include virtual="~/include/leftcolumn.inc" -->
Thanks again

Related

How can I unconfuse my server between cjshayward.com and cshayward.com?

I have separate Wordpress installations cjshayward.com and a present stub, cshayward.com. They are on the same host, with separate databases.
I would like to log in to cshayward.com, but when I load cshayward.com/wp-admin, it has the right title but the form action is cjshayward.com/wp-login.php. Whenever I try to log in to the present stub's administrative console, it bounces me to the other site.
I've tried deleting browsing history and using other browsers; I've looked in cshayward.com's wp-config.php to confirm no reference is stated to cjshayward.com, and I've looked through the Apache VirtualHost entry to confirm that HTTP connections are redirected to HTTPS and HTTPS refers to the files for the new site. Attempts to load cshayward.com/wp-admin redirect to https://cjshayward.com/wp-login.php?redirect_to=https%3A%2F%2Fcshayward.com%2Fwp-admin%2F&reauth=1 - on the old site, although the redirect URL is on the new site. The HTML is a mix of data from the old site and the new.
How can I unconfuse the installation so that attempts to load cshayward.com/wp-admin redirect correctly to the new present stub's login apparatus?
I can post non-private contents of wp-config data or query the database, but I do not presently know a reproducible way to log into the new site instead of the old, and looking at the config file plus Apache configuration has me drawing a near-blank.
The source for https://cshayward.com/wp-login.php pulls the title for the new site and specifies a form submission URL on the old site, and not the unchanged title for the old site, but specifies to send the old site a redirect URL on the new site:
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Log In ‹ C.S. Hayward: A Guide to "The Good Parts" — WordPress</title>
<meta name='robots' content='max-image-preview:large, noindex, noarchive' />
<link rel='dns-prefetch' href='//s.w.org' />
<link rel='stylesheet' id='dashicons-css' href='https://cjshayward.com/wp-includes/css/dashicons.min.css?ver=5.9.2' type='text/css' media='all' />
<link rel='stylesheet' id='buttons-css' href='https://cjshayward.com/wp-includes/css/buttons.min.css?ver=5.9.2' type='text/css' media='all' />
<link rel='stylesheet' id='forms-css' href='https://cjshayward.com/wp-admin/css/forms.min.css?ver=5.9.2' type='text/css' media='all' />
<link rel='stylesheet' id='l10n-css' href='https://cjshayward.com/wp-admin/css/l10n.min.css?ver=5.9.2' type='text/css' media='all' />
<link rel='stylesheet' id='login-css' href='https://cjshayward.com/wp-admin/css/login.min.css?ver=5.9.2' type='text/css' media='all' />
<meta name='referrer' content='strict-origin-when-cross-origin' />
<meta name="viewport" content="width=device-width" />
</head>
<body class="login no-js login-action-login wp-core-ui locale-en-us">
<script type="text/javascript">
document.body.className = document.body.className.replace('no-js','js');
</script>
<div id="login">
<h1>Powered by WordPress</h1>
<form name="loginform" id="loginform" action="https://cjshayward.com/wp-login.php" method="post">
<p>
<label for="user_login">Username or Email Address</label>
<input type="text" name="log" id="user_login" class="input" value="" size="20" autocapitalize="off" />
</p>
<div class="user-pass-wrap">
<label for="user_pass">Password</label>
<div class="wp-pwd">
<input type="password" name="pwd" id="user_pass" class="input password-input" value="" size="20" />
<button type="button" class="button button-secondary wp-hide-pw hide-if-no-js" data-toggle="0" aria-label="Show password">
<span class="dashicons dashicons-visibility" aria-hidden="true"></span>
</button>
</div>
</div>
<p class="forgetmenot"><input name="rememberme" type="checkbox" id="rememberme" value="forever" /> <label for="rememberme">Remember Me</label></p>
<p class="submit">
<input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="Log In" />
<input type="hidden" name="redirect_to" value="https://cjshayward.com/wp-admin/" />
<input type="hidden" name="testcookie" value="1" />
</p>
</form>
<p id="nav">
Lost your password?
</p>
<script type="text/javascript">
function wp_attempt_focus() {setTimeout( function() {try {d = document.getElementById( "user_login" );d.focus(); d.select();} catch( er ) {}}, 200);}
wp_attempt_focus();
if ( typeof wpOnload === 'function' ) { wpOnload() } </script>
<p id="backtoblog">
← Go to C.S. Hayward: A Guide to "The Good Parts" </p>
</div>
<script type='text/javascript' src='https://cjshayward.com/wp-includes/js/jquery/jquery.min.js?ver=3.6.0' id='jquery-core-js'></script>
<script type='text/javascript' src='https://cjshayward.com/wp-includes/js/jquery/jquery-migrate.min.js?ver=3.3.2' id='jquery-migrate-js'></script>
<script type='text/javascript' id='zxcvbn-async-js-extra'>
/* <![CDATA[ */
var _zxcvbnSettings = {"src":"https:\/\/cjshayward.com\/wp-includes\/js\/zxcvbn.min.js"};
/* ]]> */
</script>
<script type='text/javascript' src='https://cjshayward.com/wp-includes/js/zxcvbn-async.min.js?ver=1.0' id='zxcvbn-async-js'></script>
<script type='text/javascript' src='https://cjshayward.com/wp-includes/js/dist/vendor/regenerator-runtime.min.js?ver=0.13.9' id='regenerator-runtime-js'></script>
<script type='text/javascript' src='https://cjshayward.com/wp-includes/js/dist/vendor/wp-polyfill.min.js?ver=3.15.0' id='wp-polyfill-js'></script>
<script type='text/javascript' src='https://cjshayward.com/wp-includes/js/dist/hooks.min.js?ver=1e58c8c5a32b2e97491080c5b10dc71c' id='wp-hooks-js'></script>
<script type='text/javascript' src='https://cjshayward.com/wp-includes/js/dist/i18n.min.js?ver=30fcecb428a0e8383d3776bcdd3a7834' id='wp-i18n-js'></script>
<script type='text/javascript' id='wp-i18n-js-after'>
wp.i18n.setLocaleData( { 'text direction\u0004ltr': [ 'ltr' ] } );
</script>
<script type='text/javascript' id='password-strength-meter-js-extra'>
/* <![CDATA[ */
var pwsL10n = {"unknown":"Password strength unknown","short":"Very weak","bad":"Weak","good":"Medium","strong":"Strong","mismatch":"Mismatch"};
/* ]]> */
</script>
<script type='text/javascript' id='password-strength-meter-js-translations'>
( function( domain, translations ) {
var localeData = translations.locale_data[ domain ] || translations.locale_data.messages;
localeData[""].domain = domain;
wp.i18n.setLocaleData( localeData, domain );
} )( "default", { "locale_data": { "messages": { "": {} } } } );
</script>
<script type='text/javascript' src='https://cjshayward.com/wp-admin/js/password-strength-meter.min.js?ver=5.9.2' id='password-strength-meter-js'></script>
<script type='text/javascript' src='https://cjshayward.com/wp-includes/js/underscore.min.js?ver=1.13.1' id='underscore-js'></script>
<script type='text/javascript' id='wp-util-js-extra'>
/* <![CDATA[ */
var _wpUtilSettings = {"ajax":{"url":"\/wp-admin\/admin-ajax.php"}};
/* ]]> */
</script>
<script type='text/javascript' src='https://cjshayward.com/wp-includes/js/wp-util.min.js?ver=5.9.2' id='wp-util-js'></script>
<script type='text/javascript' id='user-profile-js-extra'>
/* <![CDATA[ */
var userProfileL10n = {"user_id":"0","nonce":"1ddd65e585"};
/* ]]> */
</script>
<script type='text/javascript' id='user-profile-js-translations'>
( function( domain, translations ) {
var localeData = translations.locale_data[ domain ] || translations.locale_data.messages;
localeData[""].domain = domain;
wp.i18n.setLocaleData( localeData, domain );
} )( "default", { "locale_data": { "messages": { "": {} } } } );
</script>
<script type='text/javascript' src='https://cjshayward.com/wp-admin/js/user-profile.min.js?ver=5.9.2' id='user-profile-js'></script>
<div class="clear"></div>
</body>
</html>
The "near" in near-blank is that the first, default HTTPS host in the Apache config is set to redirect to https://cjshayward.com, but this redirection should be an all or nothing deal. I can load the stub homepage from https://cshayward.com, so I don't think it is automatically redirecting; if that were happening, I'd expect a visit to the stub homepage to redirect to the original homepage, which isn't happening.
This is true after wiping and re-creating the database.
What is going on here?
I read wordpress site address is to a different site and added to wp-config.php:
define('WP_SITE_URL', 'https://cshayward.com');
define('WP_HOME', 'https://cshayward.com');
That still had things confused, but when I dropped and re-created the database with these settings in place, it stopped bouncing me to controls for the other site.
--UPDATE--
This represents an incomplete resolution.
I was able, after making these changes, to get into cshayward.com/wp-admin itself and start editing a homepage. After 15 minutes or so the editor said my session had timed out and I needed to log in again, and the login redirected me to the login for cjshayward.com.
Now the editor appears to be up to old tricks.
More specifically, if I go to the "General Settings" panel, the "Wordpress Address (URL)" entry is cjshayward.com. Furthermore, if I change it to cshayward.com and click to save my changes, it displays a value of cjshayward.com that appears to be immune to change.
From the console:
MariaDB [cshayward]> update cs_options set option_value="https://cshayward.com" where option_name = "siteurl";
Query OK, 1 row affected (0.001 sec)
Rows matched: 1 Changed: 1 Warnings: 0
MariaDB [cshayward]> select * from cs_options limit 1;
+-----------+-------------+-----------------------+----------+
| option_id | option_name | option_value | autoload |
+-----------+-------------+-----------------------+----------+
| 1 | siteurl | https://cshayward.com | yes |
+-----------+-------------+-----------------------+----------+
1 row in set (0.000 sec)
Then I reload the "General Settings" page and the option value is changed back.
MariaDB [cshayward]> select * from cs_options limit 1;
+-----------+-------------+------------------------+----------+
| option_id | option_name | option_value | autoload |
+-----------+-------------+------------------------+----------+
| 1 | siteurl | https://cjshayward.com | yes |
+-----------+-------------+------------------------+----------+
1 row in set (0.000 sec)
--ADDITIONAL UPDATE--
I had an advanced-cache.php from a copied plugin.
I have moved out all plugins except for classic editor and widgets. I do not detect any change in behavior.
--FURTHER ADDITIONAL UPDATE--
I've tried tearing down and rebuilding the site several times (including at least some of the time wiping the database as well as wiping the Wordpress installation), and have gotten apparent success for the time, but the behavior reappears.
I've added the classic editor for posts and widgets to wp-content/plugins, and twentysixteen and twentysixteen-ux-tweaks-child (the latter is the active theme at https://cjshayward.com) to wp-content/themes, and nothing else. Earlier I had a caching plugin that could have accounted to observed changes, but that has never been at the current build. Adding the definitions advocated at wordpress site address is to a different site has not changed behavior with the current site.

Data Not Filtering in Jquery Autocomplete

I've followed the examples http://jqueryui.com/autocomplete/
but instead of a fixed array I wanted a dynamic array from a database
I've almost got it working but as I type it won't filter the results and even if I type a letter that doesnt exist in the array, it still shows the full list.
search.asp
<!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">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Autocomplete - Default functionality</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.0/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.0/jquery-ui.js"></script>
<script>
$(function() {
$("#tags").autocomplete({
source: 'http://fullurl/autocomplete.asp'
});
});
</script>
</head>
<body>
<div class="ui-widget">
<label for="tags">Tags: </label>
<input id="tags">
</div>
autocomplete.asp
<%
sConn = "DRIVER={MySQL ODBC 5.1 Driver}; SERVER=SERVER; Port=3306; DATABASE=database; UID=username;PASSWORD=password; OPTION=3"
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open sConn
sSQL = "SELECT * FROM makes ORDER BY makes ASC;"
Set rst = Server.CreateObject("ADODB.Recordset")
rst.CursorLocation = 3
rst.Open sSQL, Conn, 3, 1
output = "["
DO Until rst.EOF
output = output & chr(34) & rst("makes") & chr(34) & ","
rst.movenext
Loop
output = left(output,(len(output)-1))
output = output & "]"
Response.Write output
rst.close
Conn.Close
%>
This is the result of autocomplete.asp: ["ACER","DELL","HP","LENOVO","SONY"]
any ideas what I've done wrong or missed out
Changed Jquery to the follow and works fine now
<script>
$(function() {
$.getJSON("autocomplete.asp", function(data) {
$("#tags").autocomplete({
source: data
});
});
});
</script>

Why does this var REQUEST ["name"] method always return null?

I'm self-learning how to create a form, pass the responses to a separate handler, and email them to my website account. I have the form, which works, and oddly enough, I have the mail portion working. However, this example is almost straight out of some ASP.NET help pages at Microsoft - yet it does not work, and I can't seem to find out why. What's wrong and how should it read instead?
Here's some form code:
{
<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<form action="Mailform.cshtml" enctype="text/plain"
method="post" name="formcontent">
<ul>
<li>
<label for="name" class="heavyred">Contact Name: &nbsp</label>
<input type="text" name="contact" autofocus="true" size="40"
required="" /><span class="tinyfont">&nbsp red denotes a
required field</span>
<span class="italicfont"style="margin-left: 22%"><br>Person
overseeing site development</span>
</li>
<li>
<label for="strngweak">List strengths:<br></label>
<textarea name="strngweak" placeholder="420 chars max"
cols="60" rows="7"></textarea>
</li>
</ul>
<div>
<input class="hyper buttn" style="margin-right:1%; font-size: 1em;
"type="submit" value="SUBMIT">
</div>
</form>
</body>
}
handler.cshtml code: (the first two requests end up NULL instead of getting data by name)
{
#{
var contact = Request ["contact"]; <----- NULL instead of name=contact data
var stweak = Request ["strngweak"]; <----- NULL instead of name=strngweak data
var from = "info#portalmagician.com";
var to = "sirrobcop#yahoo.com";
var subject = "I WANT A WEBSITE";
var msg = "From: ";
var errorMessage = "";
var debuggingFlag = true;
msg += contact + " Strengths: " + stweak;
}
{ try-catch block initializes webmail helper and sends email here }
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
#if (IsPost) {
if (errorMessage == "") {<p>Your message has been sent!</p>;}
else {<p>Unable to send due server down or bad server info.</p>;}
}
</body>
}
Modify the enctype of your form to application/x-www-form-urlencoded (or delete it).

#DateTime.Now function does not work for me

I have enabled IIS on my laptop and have added a folder named MyAsp.
In this folder I have a file named myfirstscript.asp with the below code.
When I run the below code I dont see the date & time. Any help would be greatly appreciated.
<!DOCTYPE HTML>
<html lang="en">
<body>
<h1>Hello Web Pages</h1>
<p>The Time is: #DateTime.Now()</p>
</body>
</html>
DateTime.Now is a property, not a method. You need to use DateTime.Now instead of DateTime.Now().
Make the changes as below
<p>The Time is: <%= DateTime.Now.ToLongTimeString() %></p>
Html
<!DOCTYPE HTML>
<html lang="en">
<body>
<h1>Hello Web Pages</h1>
<p>The Time is: <%= DateTime.Now.ToLongTimeString() %></p>
</body>
</html>
DateTime.Now.ToString();
DateTime.Now.ToShortDateString();
DateTime.Now.ToShortTimeString() ;
DateTime.Now.ToLongDateString() ;
DateTime.Now.ToLongTimeString() ;
It sounds like you need to use the asp.net inline expressions.
<p>The Time is: <%= DateTime.Now %></p>
http://support.microsoft.com/kb/976112
If it is your ASPX page then you can always use :
<%= DateTime.Now %>
But If it is your pure HTML page then you should use javascript as mentioned below :
<!DOCTYPE html>
<html lang="en">
<body onload="getDate();">
<h1>Hello Web Pages</h1> <p>The Time is: <span id="date"></span>.</p>
<script type="text/javascript" language="javascript">
function getDate() {
alert(Date());
document.getElementById('date').innerText = Date().toString();
}
</script>
</body>
</html>

Error listing files in a directory with Sinatra

I'm trying to follow along with this Sinatra tutorial (from 2008): http://devver.wordpress.com/2008/11/25/building-a-iphone-web-app-in-under-50-lines-with-sinatra-and-iui/
But ran into some problems with the code, for me the files aren't listed under the main heading currently. When I change dir to "./public/files/" the list is shown, but clicking a file's link results in an error page ("Sinatra doesn't know this ditty"). If I remove the public from the URL it will in this case work. How can I resolve the two?
Also, I get an error if with the line "use_in_file_template!", which I just comment out.
And I'm not familiar with CSS, so could someone tell me where I can the color of the text?
require 'rubygems'
require 'sinatra'
require 'pathname'
get "/" do
dir = "./files/"
#links = Dir[dir+"*"].map { |file|
file_link(file)
}.join
erb :index
end
helpers do
def file_link(file)
filename = Pathname.new(file).basename
"<li><a href='#{file}' target='_self'>#{filename}</a></li>"
end
end
use_in_file_templates!
__END__
## index
<html>
<head>
<meta name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"/>
<style type="text/css" media="screen">#import "/stylesheets/iui.css";</style>
<script type="application/x-javascript" src="/javascripts/iui.js"></script>
</head>
<body>
<div class="toolbar">
<h1 id="pageTitle"></h1>
</div>
<ul id="home" title="Your files, sir." selected="true">
<%= #links %>
</ul>
</body>
</html>
Well, sinatra (as many other web servers) assumes that public is a root directory for static files and it just does not use it when accessing files/dirs in it. So, in your case, you could change (add public to path when get list of files and remove it when generate links to them) some lines in your code:
get "/" do
dir = "public/files/"
#links = Dir[dir+"*"].map { |file|
file_link(file)
}.join
erb :index
end
helpers do
def file_link(file)
filename = Pathname.new(file).basename
"<li><a href='#{file.sub('public','')}' target='_self'>#{filename}</a></li>"
end
end

Resources