Reputation: 419
Using Microsoft Expression Web 4, I created a simple web page in which i use a ASP Connection to connect to a local Access DB. Below (at the bottom) is the source code for the entire page which works perfectly fine.
When I browse this web page (ASPX page) directly, everything works/renders fine.
However, a problem arises when I navigate to this page from a different web page. The browser states that this page contains an error:
Namespace prefix asp on FormView is not defined
Below this , another error is mentioned which states:
Unescaped '<' not allowed in attributes values
As I am inexperienced in ASP, I didn't realise I needed a Page Directive at the beginning. However, what would my page directive be?
My page is called 'Make a Booking.aspx'.
It's all HTML/CSS and a wee bit of JavaScript in parts. Here is the entire page.
<!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">
<!-- #BeginTemplate "BookingTemplate.dwt" -->
<head>
<meta content="en-gb" http-equiv="Content-Language" />
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<!-- #BeginEditable "doctitle" -->
<title>Untitled 1</title>
<!-- #EndEditable -->
<style type="text/css">
.auto-style1 {
font-family: Arial, Helvetica, sans-serif;
font-size: x-large;
}
.auto-style2 {
text-align: center;
}
.auto-style3 {
text-align: center;
font-size: xx-large;
font-family: Arial, Helvetica, sans-serif;
}
.auto-style4 {
text-align: left;
}
</style>
<script type="text/javascript">
<!--
function FP_preloadImgs() {//v1.0
var d=document,a=arguments; if(!d.FP_imgs) d.FP_imgs=new Array();
for(var i=0; i<a.length; i++) { d.FP_imgs[i]=new Image; d.FP_imgs[i].src=a[i]; }
}
function FP_swapImg() {//v1.0
var doc=document,args=arguments,elm,n; doc.$imgSwaps=new Array(); for(n=2; n<args.length;
n+=2) { elm=FP_getObjectByID(args[n]); if(elm) { doc.$imgSwaps[doc.$imgSwaps.length]=elm;
elm.$src=elm.src; elm.src=args[n+1]; } }
}
function FP_getObjectByID(id,o) {//v1.0
var c,el,els,f,m,n; if(!o)o=document; if(o.getElementById) el=o.getElementById(id);
else if(o.layers) c=o.layers; else if(o.all) el=o.all[id]; if(el) return el;
if(o.id==id || o.name==id) return o; if(o.childNodes) c=o.childNodes; if(c)
for(n=0; n<c.length; n++) { el=FP_getObjectByID(id,c[n]); if(el) return el; }
f=o.forms; if(f) for(n=0; n<f.length; n++) { els=f[n].elements;
for(m=0; m<els.length; m++){ el=FP_getObjectByID(id,els[n]); if(el) return el; } }
return null;
}
// -->
</script>
<link href="Gallery%20Styles.css" rel="stylesheet" type="text/css" />
<link href="Sperrin%20Soul%20Gallery%20styles.css" rel="stylesheet" type="text/css" />
</head>
<body onload="FP_preloadImgs(/*url*/'Media/Images/Button_Images/button75.jpg',/*url*/'Media/Images/Button_Images/button76.jpg',/*url*/'Media/Images/Button_Images/button78.jpg',/*url*/'Media/Images/Button_Images/button79.jpg',/*url*/'Media/Images/Button_Images/button7B.jpg',/*url*/'Media/Images/Button_Images/button7C.jpg',/*url*/'Media/Images/Button_Images/button7E.jpg',/*url*/'Media/Images/Button_Images/button7F.jpg',/*url*/'Media/Images/Button_Images/button81.jpg',/*url*/'Media/Images/Button_Images/button82.jpg',/*url*/'Media/Images/Button_Images/button84.jpg',/*url*/'Media/Images/Button_Images/button85.jpg')" style="height: 193px">
<table style="width: 100%">
<tr>
<td style="width: 553px">
<img alt="" height="118" src="Media/Images/Sperrin%20Soul%20Logo.jpg" style="float: right" width="285" /></td>
<td class="auto-style1"><strong><em>...discover more</em></strong></td>
</tr>
<tr>
<td class="auto-style2" colspan="2">
<img id="img1" alt="Page 1" height="20" onmousedown="FP_swapImg(1,0,/*id*/'img1',/*url*/'Media/Images/Button_Images/button76.jpg')" onmouseout="FP_swapImg(0,0,/*id*/'img1',/*url*/'Media/Images/Button_Images/button74.jpg')" onmouseover="FP_swapImg(1,0,/*id*/'img1',/*url*/'Media/Images/Button_Images/button75.jpg')" onmouseup="FP_swapImg(0,0,/*id*/'img1',/*url*/'Media/Images/Button_Images/button75.jpg')" src="Media/Images/Button_Images/button74.jpg" style="border: 0" width="100" /><!-- MSComment="ibutton" fp-style="fp-btn: Border Bottom 1" fp-title="Page 1" -->
<img id="img2" alt="Page 2" height="20" onmousedown="FP_swapImg(1,0,/*id*/'img2',/*url*/'Media/Images/Button_Images/button79.jpg')" onmouseout="FP_swapImg(0,0,/*id*/'img2',/*url*/'Media/Images/Button_Images/button77.jpg')" onmouseover="FP_swapImg(1,0,/*id*/'img2',/*url*/'Media/Images/Button_Images/button78.jpg')" onmouseup="FP_swapImg(0,0,/*id*/'img2',/*url*/'Media/Images/Button_Images/button78.jpg')" src="Media/Images/Button_Images/button77.jpg" style="border: 0" width="100" /><!-- MSComment="ibutton" fp-style="fp-btn: Border Bottom 1" fp-title="Page 2" -->
<img id="img3" alt="Page 3" height="20" onmousedown="FP_swapImg(1,0,/*id*/'img3',/*url*/'Media/Images/Button_Images/button7C.jpg')" onmouseout="FP_swapImg(0,0,/*id*/'img3',/*url*/'Media/Images/Button_Images/button7A.jpg')" onmouseover="FP_swapImg(1,0,/*id*/'img3',/*url*/'Media/Images/Button_Images/button7B.jpg')" onmouseup="FP_swapImg(0,0,/*id*/'img3',/*url*/'Media/Images/Button_Images/button7B.jpg')" src="Media/Images/Button_Images/button7A.jpg" style="border: 0" width="100" /><!-- MSComment="ibutton" fp-style="fp-btn: Border Bottom 1" fp-title="Page 3" -->
<img id="img4" alt="Page 4" height="20" onmousedown="FP_swapImg(1,0,/*id*/'img4',/*url*/'Media/Images/Button_Images/button7F.jpg')" onmouseout="FP_swapImg(0,0,/*id*/'img4',/*url*/'Media/Images/Button_Images/button7D.jpg')" onmouseover="FP_swapImg(1,0,/*id*/'img4',/*url*/'Media/Images/Button_Images/button7E.jpg')" onmouseup="FP_swapImg(0,0,/*id*/'img4',/*url*/'Media/Images/Button_Images/button7E.jpg')" src="Media/Images/Button_Images/button7D.jpg" style="border: 0" width="100" /><!-- MSComment="ibutton" fp-style="fp-btn: Border Bottom 1" fp-title="Page 4" -->
<img id="img5" alt="Page 5" height="20" onmousedown="FP_swapImg(1,0,/*id*/'img5',/*url*/'Media/Images/Button_Images/button82.jpg')" onmouseout="FP_swapImg(0,0,/*id*/'img5',/*url*/'Media/Images/Button_Images/button80.jpg')" onmouseover="FP_swapImg(1,0,/*id*/'img5',/*url*/'Media/Images/Button_Images/button81.jpg')" onmouseup="FP_swapImg(0,0,/*id*/'img5',/*url*/'Media/Images/Button_Images/button81.jpg')" src="Media/Images/Button_Images/button80.jpg" style="border: 0" width="100" /><!-- MSComment="ibutton" fp-style="fp-btn: Border Bottom 1" fp-title="Page 5" -->
<img id="img6" alt="Page 6" height="20" onmousedown="FP_swapImg(1,0,/*id*/'img6',/*url*/'Media/Images/Button_Images/button85.jpg')" onmouseout="FP_swapImg(0,0,/*id*/'img6',/*url*/'Media/Images/Button_Images/button83.jpg')" onmouseover="FP_swapImg(1,0,/*id*/'img6',/*url*/'Media/Images/Button_Images/button84.jpg')" onmouseup="FP_swapImg(0,0,/*id*/'img6',/*url*/'Media/Images/Button_Images/button84.jpg')" src="Media/Images/Button_Images/button83.jpg" style="border: 0" width="100" /><!-- MSComment="ibutton" fp-style="fp-btn: Border Bottom 1" fp-title="Page 6" --></td>
</tr>
<tr>
<td colspan="2">
<p class="auto-style3"><strong><em><!-- #BeginEditable "Page_Title" -->
(Page_Title)<!-- #EndEditable --></em></strong></p>
</td>
</tr>
</table>
<br />
<div style="height: 655px">
<div id="div_container" class="auto-style4" style="font-family: Arial, Helvetica, sans-serif; margin-top: 1cm; margin-right: auto; margin-left: auto; padding: 10px; width: 1200px; text-align: center;">
<!-- #BeginEditable "Box_left" -->
<div id="div_left" style="font-family: Arial, Helvetica, sans-serif; font-size: medium; border: medium solid #C0C0C0; border-radius: 8px; padding: 8px; width: 700px; display: inline-block; vertical-align: top;">
<h1>Make an online Booking!</h1>
<h1><br />
</h1>
<form id="form1" runat="server">
<div class="auto-style4">
<br />
To make a new booking please click on '<strong>New</strong>'
below:<br />
</div>
<div class="auto-style4">
<asp:FormView id="FormView1" runat="server" AllowPaging="True" BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid" BorderWidth="3px" CellPadding="4" CellSpacing="2" DataKeyNames="BookingID" DataSourceID="AccessDataSource1" Font-Bold="False" ForeColor="Black" GridLines="Both">
<EditItemTemplate>
BookingID:
<asp:Label id="BookingIDLabel1" runat="server" Text='<%# Eval("BookingID") %>' />
<br />
CustomerName:
<asp:TextBox id="CustomerNameTextBox" runat="server" Text='<%# Bind("CustomerName") %>' />
<br />
BookingDate:
<asp:TextBox id="BookingDateTextBox" runat="server" Text='<%# Bind("BookingDate") %>' />
<br />
EventType:
<asp:TextBox id="EventTypeTextBox" runat="server" Text='<%# Bind("EventType") %>' />
<br />
NumInGroup:
<asp:TextBox id="NumInGroupTextBox" runat="server" Text='<%# Bind("NumInGroup") %>' />
<br />
<asp:LinkButton id="UpdateButton" runat="server" CausesValidation="True" CommandName="Update" Text="Update" />
<asp:LinkButton id="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</EditItemTemplate>
<EditRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
<FooterStyle BackColor="#CCCCCC" />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
<InsertItemTemplate>
CustomerName:
<asp:TextBox id="CustomerNameTextBox0" runat="server" Text='<%# Bind("CustomerName") %>' />
<br />
BookingDate:
<asp:TextBox id="BookingDateTextBox0" runat="server" Text='<%# Bind("BookingDate") %>' />
<br />
EventType:
<asp:TextBox id="EventTypeTextBox0" runat="server" Text='<%# Bind("EventType") %>' />
<br />
NumInGroup:
<asp:TextBox id="NumInGroupTextBox0" runat="server" Text='<%# Bind("NumInGroup") %>' />
<br />
<asp:LinkButton id="InsertButton" runat="server" CausesValidation="True" CommandName="Insert" Text="Insert" />
<asp:LinkButton id="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</InsertItemTemplate>
<ItemTemplate>
BookingID:
<asp:Label id="BookingIDLabel" runat="server" Text='<%# Eval("BookingID") %>' />
<br />
CustomerName:
<asp:Label id="CustomerNameLabel" runat="server" Text='<%# Bind("CustomerName") %>' />
<br />
BookingDate:
<asp:Label id="BookingDateLabel" runat="server" Text='<%# Bind("BookingDate") %>' />
<br />
EventType:
<asp:Label id="EventTypeLabel" runat="server" Text='<%# Bind("EventType") %>' />
<br />
NumInGroup:
<asp:Label id="NumInGroupLabel" runat="server" Text='<%# Bind("NumInGroup") %>' />
<br />
<asp:LinkButton id="EditButton" runat="server" CausesValidation="False" CommandName="Edit" Text="Edit" />
<asp:LinkButton id="DeleteButton" runat="server" CausesValidation="False" CommandName="Delete" Text="Delete" />
<asp:LinkButton id="NewButton" runat="server" CausesValidation="False" CommandName="New" Text="New" />
</ItemTemplate>
<PagerStyle BackColor="#CCCCCC" ForeColor="Black" HorizontalAlign="Left" />
<RowStyle BackColor="White" />
</asp:FormView>
</div>
<asp:AccessDataSource id="AccessDataSource1" runat="server" DataFile="BookingDB.mdb" DeleteCommand="DELETE FROM [tbl_Booking] WHERE [BookingID] = ?" InsertCommand="INSERT INTO [tbl_Booking] ([CustomerName], [BookingDate], [EventType], [NumInGroup]) VALUES (?, ?, ?, ?)" SelectCommand="SELECT [BookingID], [CustomerName], [BookingDate], [EventType], [NumInGroup] FROM [tbl_Booking]" UpdateCommand="UPDATE [tbl_Booking] SET [CustomerName] = ?, [BookingDate] = ?, [EventType] = ?, [NumInGroup] = ? WHERE [BookingID] = ?">
<DeleteParameters>
<asp:Parameter Name="BookingID" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="CustomerName" Type="String" />
<asp:Parameter Name="BookingDate" Type="DateTime" />
<asp:Parameter Name="EventType" Type="String" />
<asp:Parameter Name="NumInGroup" Type="Int16" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="CustomerName" Type="String" />
<asp:Parameter Name="BookingDate" Type="DateTime" />
<asp:Parameter Name="EventType" Type="String" />
<asp:Parameter Name="NumInGroup" Type="Int16" />
<asp:Parameter Name="BookingID" Type="Int32" />
</UpdateParameters>
</asp:AccessDataSource>
<div class="auto-style4">
<br />
Please view all our current bookings below:<asp:GridView id="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid" BorderWidth="3px" CellPadding="4" CellSpacing="2" DataKeyNames="BookingID" DataSourceID="AccessDataSource2" ForeColor="Black">
<Columns>
<asp:BoundField DataField="BookingID" HeaderText="BookingID" InsertVisible="False" ReadOnly="True" SortExpression="BookingID">
</asp:BoundField>
<asp:BoundField DataField="CustomerName" HeaderText="CustomerName" SortExpression="CustomerName">
</asp:BoundField>
<asp:BoundField DataField="BookingDate" HeaderText="BookingDate" SortExpression="BookingDate">
</asp:BoundField>
<asp:BoundField DataField="StartTime" HeaderText="StartTime" SortExpression="StartTime">
</asp:BoundField>
<asp:BoundField DataField="EventType" HeaderText="EventType" SortExpression="EventType">
</asp:BoundField>
<asp:BoundField DataField="NumInGroup" HeaderText="NumInGroup" SortExpression="NumInGroup">
</asp:BoundField>
</Columns>
<FooterStyle BackColor="#CCCCCC" />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#CCCCCC" ForeColor="Black" HorizontalAlign="Left" />
<RowStyle BackColor="White" />
<SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#808080" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#383838" />
</asp:GridView>
<br />
<asp:AccessDataSource id="AccessDataSource2" runat="server" DataFile="BookingDB.mdb" SelectCommand="SELECT [BookingID], [CustomerName], [BookingDate], [StartTime], [EventType], [NumInGroup] FROM [tbl_Booking]">
</asp:AccessDataSource>
<br />
<br />
<br />
</div>
</form>
</div>
<!-- #EndEditable -->
<!-- #BeginEditable "Box_Right" -->
<div id="div_right" style="font-family: Arial, Helvetica, sans-serif; font-size: medium; border: medium solid #66CCFF; border-radius: 8px; padding: 8px; width: 300px; display: inline-block; text-align: center;">
<div class="VerticalPictureplaceholder">
<img alt="" src="Media/Images/Online_Booking.jpg" />
</div>
<div class="Description">make on instant online booking!</div>
<div class="VerticalPictureplaceholder">
<img alt="" src="Media/Images/Book-Online.jpg" />
</div>
<div class="Description">Enjoy walking the mountains</div>
<div class="VerticalPictureplaceholder">
<img alt="" src="Media/Images/phone%20call.jpg" />
</div>
<div class="Description">A natural wonder</div>
</div>
<!-- #EndEditable -->
</div>
<div id="div_footer" class="auto-style2" style="font-family: Arial, Helvetica, sans-serif; margin-left: auto; margin-right: auto">
<em>updated on 19/12/2019<br />
contact [email protected]</em></div>
</div>
</body>
<!-- #EndTemplate -->
</html>
Upvotes: 4
Views: 1003
Reputation: 5294
You need to have page directory on top of the Asp page.
<%@ Page Title="YourTitle" Language="C#" AutoEventWireup="false" CodeBehind="YourCodeBehind.aspx.cs" Inherits="YourCodeBehindNamspace" %>
Also please check if your web server configured to use the .Net framework? It sounds like the ASP.Net ISAPI filter is not picking up and translating the page.
Upvotes: 0
Reputation: 419
Within Microsoft Expression Web 4, under Site > Site Settings there is an option for Previewing web pages, using Microsoft Expression Development Server. It was set to the option:
For only PHP and ASP.NET web pages
To fix the problem, I had to select the second option:
For ALL web pages.
It effectively means that i'm previewing all my web pages (HTML and ASPX pages) from LocalHost.
Upvotes: 0
Reputation: 35544
It seems that you copied the FormView code from somewhere and pasted it in an .aspx file correct?
If so, a standalone aspx page should look like this. This limits the code you can use since there is no code behid file where more complex actions are handled.
<%@ Page Language="C#" %>
<!DOCTYPE html>
<html>
<head>
<title>Demo</title>
</head>
<body>
<form runat="server" id="form1">
<asp:FormView ID="FormView1" runat="server" DataSourceID="SqlDataSource1">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("column1") %>' />
or
<%# Eval("column1") %>
</ItemTemplate>
</asp:FormView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="MyConnectionString" SelectCommand="select * from mytable" />
</form>
</body>
</html>
See these links for more info. But if you go and do more on an aspx page I would recommend creating a project in Visual Studio and work from there.
http://www.beansoftware.com/ASP.NET-Tutorials/FormView-Control.aspx
https://www.c-sharpcorner.com/UploadFile/abhikumarvatsa/formview-control-in-Asp-Net-part-12/
https://www.aspsnippets.com/Articles/GridView-FormView-Master-Detail-example-in-ASPNet.aspx
https://www.tutorialride.com/asp-net/detailsview-and-formview-controls-in-asp-net.htm
Upvotes: 1