In the web applcation there is a .aspx page which doesnt have the code behind file(.cs). it is in folder called staticcontent The below is the markup of 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>
Now i want to move this search text box to asp.net and register in this page.
However it is not getting compiled it seems.
It still render the syntax of user control only
<%@ Register Src="~/controls/EmpSearch.ascx" TagName="search" TagPrefix="emp" %>
<emp:search runat="server" ID="searchCtrl"></emp:search>
Rendered HTML
<body>
This contains only static text and there is no dynamic data
Employee Search
<emp:search runat="server" ID="searchCtrl"></emp:search>
</body>
Tried using <!--#include file="~/controls/EmpSearch.ascx"--> no impact.
How come .aspx page is not compiled here.
The .csproj has only <Content Include="StaticContent\Employee.aspx" />
and doesn't have
<Compile Include="StaticContent\Employee.aspx.cs">
since it dont have code behind
Difficult to tell without the whole markup, but I would say that you might have some configuration that makes files stored in your staticcontent folder be treated as static content :-) and not be passed to asp.net for compilation/execution.
Have a look in your web.config or IIS at the configuration of the static content folder.
For information, this works on my dev server :
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"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With