没有定义在FormView的命名空间前缀ASP - 什么是我的页面指令?

问题描述 投票:3回答:3

使用Microsoft Expression Web的4,我创建了一个简单的网页中,我使用ASP连接连接到本地Access数据库。下面(底部)是其工作完全正常整个页面的源代码。

当我浏览这个网页(ASPX页面)直接,一切正常/精细渲染。

但是,当我浏览这个网页从不同的网页出现问题。浏览器指出,此页面包含一个错误:

在FormView的命名空间前缀ASP是没有定义

下面这个,提到另一个错误的规定:

未逸出“<”中的属性值不允许

正如我在ASP我没有经验,我没有意识到我需要一个Page指令开头。然而,就我的页面指令是什么呢?

我的页面被称为“做一个Booking.aspx”。

这是所有的HTML / CSS和JavaScript的部分一丁点儿。这里是整个页面。

<!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" -->&nbsp;
        <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" -->&nbsp;
        <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" -->&nbsp;
        <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" -->&nbsp;
        <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" -->&nbsp;
        <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" />
                        &nbsp;<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" />
                        &nbsp;<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" />
                        &nbsp;<asp:LinkButton id="DeleteButton" runat="server" CausesValidation="False" CommandName="Delete" Text="Delete" />
                        &nbsp;<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>
html asp.net forms
3个回答
1
投票

看来你从什么地方抄FormView控件的代码并粘贴它在.aspx文件中是否正确?

如果是这样,一个独立的ASPX页面看起来应该像这样。这限制了可以使用,因为没有代码behid文件,其中更复杂的动作被处理的代码。

<%@ 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>

看到这些链接,了解更多信息。但是如果你去多做一个aspx页面上,我建议建立从那里在Visual Studio中的项目和工作。

http://www.beansoftware.com/ASP.NET-Tutorials/FormView-Control.aspx

https://docs.microsoft.com/en-us/aspnet/web-forms/overview/data-access/custom-formatting/using-the-formview-s-templates-cs

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


0
投票

在微软的Expression Web 4,网站>网站设置下,没有用于预览网页,使用Microsoft表达式开发服务器的选项。它被设置为选项:

仅适用于PHP和ASP.NET网页

要解决这个问题,我不得不选择第二个选项:

对于所有网页。

这实际上意味着,我是预览从本地主机我所有的网页(HTML和ASPX页面)。


0
投票

您需要对ASP页的顶部页目录。

<%@ Page Title="YourTitle" Language="C#" AutoEventWireup="false" CodeBehind="YourCodeBehind.aspx.cs" Inherits="YourCodeBehindNamspace" %>

也请检查您的Web服务器配置为使用.NET框架?这听起来像ASP.Net ISAPI筛选器不拾取和翻译的页面。

© www.soinside.com 2019 - 2024. All rights reserved.