2013-10-11 58 views
4

在Web的applcation存在的.aspx页面其中doesnt have the code behind file(.cs)。它是在叫staticcontent的文件夹下面是ASP.Net页面是没有得到编译

<%@ 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,该页面中注册的aspx的标记。

但是它没有得到编译它似乎。

它仍然呈现的用户控件只

<%@ Register Src="~/controls/EmpSearch.ascx" TagName="search" TagPrefix="emp" %> 
<emp:search runat="server" ID="searchCtrl"></emp:search> 

渲染HTML

<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"> 

,因为它不具有背后

+3

如果你还没有代码隐藏,这是未编译,请阅读页面生命周期! –

+0

@RameshRajendran代码后面是可选的只有,读[这里](http://msdn.microsoft.com/en-us/magazine/cc163512.aspx)'ASP.NET,从版本1.0。正如大多数Web开发人员现在应该知道的那样,ASP.NET页面通常以一个或两个文件编写:.aspx标记文件和可选的代码隐藏文件。代码隐藏包含以任何受支持的编程语言编写的类文件,但通常是Visual Basic或C#。 .aspx标记文件包含HTML标记,ASP.NET控件标记和形成页面结构的文字(它也可以包含代码)。 –

回答

3

很难分辨不整的标记代码,但我要说的是,你可能有一些配置使存储在您的staticcontent文件夹中的文件被视为静态内容:-),并且不会传递给asp.net进行编译/执行。

有一个在静态内容文件夹的配置你的web.config或IIS看看。

的信息,这个工作我的dev的服务器:

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"/> 
相关问题