ASP.Net 页面未编译
本文关键字:编译 Net ASP | 更新日期: 2023-09-27 18:35:08
在Web应用程序中有一个.aspx页面,该页面doesnt have the code behind file(.cs)
。 它位于名为staticcontent
的文件夹中 下面是aspx的标记
<%@ Page Title="" Language="C#" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
</head>
<body>
<form action='searchdata.aspx' method='post'>
<input type='text' value='' id='searchText' />
<button id='btnSearch'>Search</button>
</form>
</body>
</html>
现在我想将此搜索文本框移动到 asp.net 并在此页面中注册。
但是,它似乎没有被编译。
它仍然仅呈现用户控件的语法
<%@ Register Src="~/controls/EmpSearch.ascx" TagName="search" TagPrefix="emp" %>
<emp:search runat="server" ID="searchCtrl"></emp:search>
呈现的网页
<body>
This contains only static text and there is no dynamic data
Employee Search
<emp:search runat="server" ID="searchCtrl"></emp:search>
</body>
尝试使用<!--#include file="~/controls/EmpSearch.ascx"-->
没有影响。
为什么.aspx页面不在这里编译。
.csproj has only <Content Include="StaticContent'Employee.aspx" />
并且没有
<Compile Include="StaticContent'Employee.aspx.cs">
因为它没有隐藏的代码
没有整个标记很难分辨,但我想说你可能有一些配置,使存储在staticcontent
文件夹中的文件被视为静态内容:-)并且不会传递给 asp.net 进行编译/执行。
查看 web.config 或 IIS 中静态内容文件夹的配置。
有关信息,这适用于我的开发服务器:
WebForm1.aspx :
<%@ Page Language="C#"%>
<%@ Register Src="~/WebUserControl1.ascx" TagPrefix="uc1" TagName="WebUserControl1" %>
<html>
<head>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<uc1:WebUserControl1 runat="server" ID="WebUserControl1" />
</form>
</body>
</html>
WebUserControl1.ascx :
<%@ Control Language="C#"%>
<asp:TextBox runat="server" ID="tbSearch"></asp:TextBox>
<asp:Button runat="server" Text="Search"/>