kf4vbc
02-24-2009, 10:56 AM
I have multiple URLs pointing to the same web server IP address. When a page is opened I want to read the hostname and use it to look up a record in a SQL database. I will then display a photo from a link found in that database. Can I do this using Dreamweaver on an ASP.net server? Here is the source code I have been trying. Note: if I change the site name in the JavaScript to “window.listname.hostname” I get a “JS1135: Variable 'window' has not been declared” error.
<%@LANGUAGE="JAVASCRIPT" Debug="true" CODEPAGE="65001"%>
<%@ Register TagPrefix="MM" Namespace="DreamweaverCtrls" Assembly="DreamweaverCtrls,version=1.0.0.0,publicKeyToken=836f606ede05d46a,culture=neutral" %>
<MM:DataSet
id="DataSet1"
runat="Server"
IsStoredProcedure="false"
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_STRING_MLSPublic") %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_DATABASETYPE_MLSPublic") %>'
CommandText='<%# "SELECT * FROM dbo.Agent WHERE AgentHost = @AgentHost" %>'
Debug="true"
>
<Parameters>
<Parameter Name="@AgentHost" Value='<%# getHostname() %>' Type="VarChar" />
</Parameters>
</MM:DataSet>
<MM:PageBind runat="server" PostBackBind="true" />
<!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 http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Multiple URL test</title>
<script language="javascript" runat="server">
function getHostname(){
var hostURL = "www.bettysmithrealestateagent.com"
return hostURL
}
</script>
</head>
<body>
<SCRIPT language="JavaScript">
<!--
document.write ("Hostname: ")
document.write (window.location.hostname)
//-->
</SCRIPT>
<hr />
Agent ID: <%# DataSet1.FieldValue("AgentID", Container) %>
<hr />
Agent PICurl: <img border="0" src="<%# DataSet1.FieldValue("AgentPICurl", Container) %>">
<hr />
</body>
</html>
<%@LANGUAGE="JAVASCRIPT" Debug="true" CODEPAGE="65001"%>
<%@ Register TagPrefix="MM" Namespace="DreamweaverCtrls" Assembly="DreamweaverCtrls,version=1.0.0.0,publicKeyToken=836f606ede05d46a,culture=neutral" %>
<MM:DataSet
id="DataSet1"
runat="Server"
IsStoredProcedure="false"
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_STRING_MLSPublic") %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_DATABASETYPE_MLSPublic") %>'
CommandText='<%# "SELECT * FROM dbo.Agent WHERE AgentHost = @AgentHost" %>'
Debug="true"
>
<Parameters>
<Parameter Name="@AgentHost" Value='<%# getHostname() %>' Type="VarChar" />
</Parameters>
</MM:DataSet>
<MM:PageBind runat="server" PostBackBind="true" />
<!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 http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Multiple URL test</title>
<script language="javascript" runat="server">
function getHostname(){
var hostURL = "www.bettysmithrealestateagent.com"
return hostURL
}
</script>
</head>
<body>
<SCRIPT language="JavaScript">
<!--
document.write ("Hostname: ")
document.write (window.location.hostname)
//-->
</SCRIPT>
<hr />
Agent ID: <%# DataSet1.FieldValue("AgentID", Container) %>
<hr />
Agent PICurl: <img border="0" src="<%# DataSet1.FieldValue("AgentPICurl", Container) %>">
<hr />
</body>
</html>