Custom UserControl is not registering in ASP.NET - asp.net

Update: J0e3gan tried my code in his own project, and it worked fine (with a minor correction), so the problem appears to be with Visual Studio itself, rather than the code or markup. I have tried adding a new UserControl as well, and it was not recognized either. However, VS is recognizing the AjaxControlToolkit that is registered in web.config just fine. [/update]
I'm trying to add a custom UserControl named AdminControls to the site I'm working on, but I keep getting the following error:
Element 'ControlName' is not a known element. This can occur if there is a compilation error in the Web site, or the web.config file is missing.
I'm running Visual Studio Pro 2013, and the project is a Web Application. I have searched the Web for solutions, mostly here on Stack Overflow, and have tried every one I could find, but have had no luck. There must be something I'm missing.
Here is the markup for AdminControls:
<asp:Table ID="tblAdminControls" runat="server">
<asp:TableRow>
<asp:TableCell style="min-width: 50%;"> </asp:TableCell>
<asp:TableCell style="width: 6em" id="tdCP" runat="server">
<asp:Button Font-Bold="true" Font-Size="Smaller" Font-Overline="false" ID="btnCP"
runat="server" CssClass="Button" Text="Control Panel" />
</asp:TableCell>
<asp:TableCell style="width: 5em">
<asp:Button Font-Bold="true" Font-Size="Smaller" Font-Overline="false" ID="btnLogOut"
runat="server" CssClass="Button" Text="LogOut" />
</asp:TableCell>
</asp:TableRow>
</asp:Table>
And here is the codebehind for it:
Public Class AdminControls
Inherits System.Web.UI.UserControl
Private Sub Page_Init(sender As Object, e As EventArgs) Handles Me.Init
If Request.ServerVariables("SCRIPT_NAME") = "/frmAdminCP.aspx" Then
tdCP.Visible = False
End If
End Sub
Private Sub btnCP_Click(sender As Object, e As EventArgs) Handles btnCP.Click
Response.Redirect("frmAdminCP.aspx", False)
End Sub
Private Sub btnLogOut_Click(sender As Object, e As EventArgs) Handles btnLogOut.Click
Session.RemoveAll()
Session.Abandon()
Response.Redirect("frmLogin.aspx", False)
End Sub
End Class
I've tried registering AdminControls both in the web.config file and on the page. Here's the relevant bits from the web.config file:
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID">
<controls>
<add tagPrefix="ajaxToolkit" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" />
<add tagPrefix="klc" tagName="AdminHeader" src="~/AdminControls.ascx" />
</controls>
</pages>
And last but not least, here's one of the pages I'm trying to put AdminControls in:
<%# Page Title="" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false"
EnableEventValidation="false" Inherits="ProjectName.frmAdminCP" CodeBehind="frmAdminCP.aspx.vb" %>
<%# Register TagPrefix="klc" TagName="AdminHeader" Src="~/Controls/AdminControls.ascx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<div id="content">
<h1>Admin <span class="pagetitle">Control Panel</span> </h1>
<klc:AdminHeader runat="server" id="ahControls" />
<div>
<h2>Users</h2>
View Existing Users<br />
Add a New User
<h2>Usage Reports</h2>
View User Activity Report<br />
View Administrative Log
<h2>Project Management</h2>
View Projects<br />
Manage Project Files
</div>
</div>
</asp:Content>
I have attempted every fix I've come across, even if they seemed ridiculous. I've:
Purged the schema cache.
Cleaned and rebuilt the solution.
Restarted Visual Studio.
Restarted my computer.
Moved the file to a subdirectory.
Cut and pasted the code and markup to the same place and resaved the files.
There are no build errors, and the tagPrefix does not appear in the Intellisense auto-complete dropdown.
Can anyone see any errors I've made, or does anyone know of a solution I haven't tried yet? I haven't tried slaughtering a black rooster over my PC yet, but I'm getting close.

Using the code you provided, I successfully included your user control in a page - screenshot below. I was unable to reproduce the error you are getting.
The only error I encountered along the way stemmed from the two different paths you used for AdminControls.ascx:
src="~/AdminControls.ascx" your Web.config excerpt.
Src="~/Controls/AdminControls.ascx" in your (frmAdminCP.aspx) page excerpt.
Once I made the paths consistent (with each other and the scrach web app project I created), AdminControls showed up in frmAdminCP.aspx just fine:
In case it helps you, for my sanity check I simply created a new ASP.NET Web Forms Application project in Visual Studio 2013 targeting .NET 4.0, added a new Web Forms User Control item named AdminControls.ascx, added a new Web Form item named frmAdminCP.aspx, and pasted your code in all the appropriate places.

I understand I'm a bit late to this answer, but I found a solution.
I was experiencing the same issue where I was attempting to register a custom control but Visual Studio wasn't recognizing it. I was able to resolve this by going to Build->Build Page. After VS finished analyzing and building the page, the error/warning I was getting went away.

Related

DX DateEdit controls break inside of an ACT Accordion control

I've got several DevExpress DateEdit controls on my page organized into an AjaxControlToolkit Accordion along with other fields relevant to my data.
The DateEdit controls worked quite fine until I put them into the Accordion so I'm assuming the problem is some conflict between DevExpress and AjaxControlToolkit though I have no other alternative unless there's a DX accordion type control that does the same as the one from the Control Toolkit...
The error I'm getting in my browser when I try to use a date editor is
ASPx is not defined
No other details that I could find but DateEdit fields placed outside of the Accordion work perfectly.
Note that removing the accordion is not a viable solution for this project without a possible alternative being presented.
Here's my code:
<%# Register TagPrefix="ajax" Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" %>
<%# Register Assembly="DevExpress.Web.v15.2, Version=15.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web" TagPrefix="dx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="cphContent" runat="server">
<asp:UpdatePanel runat="server" ID="upAlerts">
<ContentTemplate>
<ajax:Accordion runat="server" ID="Accordion1" EnableViewState="true" CssClass="panel panel-info"
HeaderCssClass="panel-heading" ContentCssClass="panel-body">
<Panes>
<ajax:AccordionPane runat="server" ID="apAlert">
<Header>
<h3>Alert Details</h3>
</Header>
<Content>
<div class="form-group">
<label for="dtDate">Date</label>
<dx:ASPxDateEdit ID="dtDate" runat="server" DisplayFormatString="yyyy/MM/dd" CssClass="form-control"></dx:ASPxDateEdit>
</div>
</Content>
</ajax:AccordionPane>
</Panes>
</ajax:Accordion>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
​I would normally suspect the problem to actually exist with the ViewState since I know these controls (ACT ones in particular) can mess with the ViewState quite a lot, but the Accordion isn't currently disabling the ViewState so I'm prepared to rule that out as a possibility at this point.
That said, I'm all out of ideas.
I even tried to rearrange the order in which the assemblies are registered on the page so that DevExpress is being registered after Ajax in an attempt to ensure that Ajax wasn't overriding anything that DevExpress needed.
As a last resort I tried switching the DevExpress date editors to Ajax calendar extenders but for some weird reason they don't render correctly either (no dates are visible on the calendar pop out).
How can I get these DateEdit controls working?

TextBoxWatermarkExtender

i am new to asp.net and i was to work in AjaxControlToolkit and i instaled and performed other operation but it is showing me report...,
error is:
The type name 'TextBoxWatermarkExtender' does not exist in the type 'AjaxControlToolkit'
protected global::AjaxControlToolkit.TextBoxWatermarkExtender TextBoxWatermarkExtender1;
code is:
<asp:TextBoxWatermarkExtender id="TBWEDOB" runat="server" targetcontrolid="txtDOB"
watermarktext="dd/mm/yy" watermarkcssclass="watermarked"> </asp:TextBoxWatermarkExtender>
plz any one pelp me on this flow....,
First Check This
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
in Your Page and see what is the TagPrefix in your page and than use that.like
<asp:TextBoxWatermarkExtender ID="TBWE2" runat="server"
TargetControlID="TextBox1"
WatermarkText="Type First Name Here"
WatermarkCssClass="watermarked" />
it will work defiantly
Why don't you simply try placeholder property to achieve the watermark in input fields.
Yes, There is a restriction of older browser, so if you are working with newer version (suppots HTML 5) then you can use it like this
<asp:TextBox ID="textbox1" runat="server" placeholder="dd/mm/yyyy"></asp:TextBox>
You haven't provided much information so it will be tough to identify where your mistake is, here's a simple step-by-step list of how you can use AJAX in your application, just follow the points below and it will work:
1) Download AJAX from codeplex, save and unzip anywhere on your machine
2) In Visual Studio Toolbox, Right click-> Add Tab, give it a name
3) Right click the newly created tab -> Choose Items...
4) Click Browse, find AjaxControlToolkit.dll and click OK
5) If all is well the controls will be added to your toolbox
6) Drag and drop a ToolkitScriptManager to the .aspx page, doing this will automatically:
6.1) Add a AjaxControlToolkit.dll reference to your project
6.2) Add the following line to the source view of your page
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
7)Drag and drop a TextBoxWatermarkExtender to the .aspx page and you're done:
<asp:ToolkitScriptManager ID="sm" runat="server" />
<asp:TextBoxWatermarkExtender ID="watermark" runat="server" TargetControlID="txtName" WatermarkText="Type name here..." />
<asp:TextBox ID="txtName" runat="server" />
try modifying the tag prefix
on the top of the page register the ajax tool kit.
<%# Register Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit" TagPrefix="ajax" %>
<ajax:TextBoxWatermarkExtender id="TBWEDOB" runat="server" targetcontrolid="txtDOB"
watermarktext="dd/mm/yy" watermarkcssclass="watermarked"> </ajax:TextBoxWatermarkExtender>

Element 'RadGrid' is not a known element

I'm trying to use the Telerik RadGrid, but I'm getting the following warning:
"Element 'RadGrid' is not a known element. This can occur if there is
a compilation error in the Web site, or the web.config file is
missing."
Here are some things that I've already checked:
The web.config file isn't missing, and there aren't any other
compilation problems on the page.
The Telerik.Web.UI dll is in the GAC, and the project's references
point to that file. No Telerik dlls in the bin folder.
The assembly is added in the web.config using this in the assemblies
section: <add assembly="Telerik.Web.UI, Version=2011.1.413.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4"/>
The properties of the RadGrid work, so Visual Studio is able to
figure out what the object is
The page runs normally, I just have this annoying set of
warnings.
I tried adding an #Register statement for the Telerik assembly on the page, but got no change
I tried clean/rebuild, but no change
I tried restarting Visual Studio, no change
I tried restarting the machine, no change
EDIT:
Here's the markup I'm using.
<%# Page Title="" Language="C#" MasterPageFile="~/masterPages/ActionAreaSinglePanelMaster.Master" AutoEventWireup="true" CodeBehind="overview.aspx.cs" Inherits="Compass.overview" %>
<asp:Content ID="PanelHeaderContent" ContentPlaceHolderID="PanelHeaderPlaceholder" runat="server">
<p>Panel header</p>
</asp:Content>
<asp:Content ID="PanelContent" ContentPlaceHolderID="PanelDataPlaceholder" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<script src="../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script src="../Scripts/radGridLayout.js" type="text/javascript"></script>
<script type="text/javascript">
panelGridID = "<%=panelGrid.ClientID %>";
</script>
<asp:ObjectDataSource ID="BundleItemsSource" runat="server" TypeName="Compass.Data.CompassUI" SelectMethod="BundleDataSet">
<SelectParameters>
<asp:QueryStringParameter Name="bundleID" QueryStringField="bundle" />
</SelectParameters>
</asp:ObjectDataSource>
<telerik:RadGrid id="panelGrid" runat="server" DataSourceID="BundleItemsSource" Height="100%" Width="100%">
<ClientSettings>
<Scrolling AllowScroll="True" UseStaticHeaders="True" />
<ClientEvents OnGridCreated="gridCreated" />
</ClientSettings>
</telerik:RadGrid>
</asp:Content>
Close Visual Studio, delete the schema cache, and re-open Visual Studio. You can find the schemas under something like:
C:\Users\karthik\AppData\Roaming\Microsoft\VisualStudio\10.0\ReflectedSchemas
It is safe to delete all files in this folder.
Changing the Assembly attribute to remove the specific version, public key, etc apparently fixed the problems.

The name 'GridView1' does not exist in the current context

I have two files named as TimeSheet.aspx.cs and TimSheet.aspx ,code of the file are given below for your reference.
when i build the application im getting error "The name 'GridView1' does not exist in the current context" even thought i have a control with the id GridView1 and i have added the runat="server" as well.
Im not able to figure out what is causing this issue.Can any one figure whats happen here.
Thanks & Regards,
=======================================
TimeSheet.aspx.cs
=======================================
#region Using directives
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using TSMS.Web.UI;
#endregion
public partial class TimeSheets: Page
{
protected void Page_Load(object sender, EventArgs e)
{
FormUtil.RedirectAfterUpdate(GridView1, "TimeSheets.aspx?page={0}");
FormUtil.SetPageIndex(GridView1, "page");
FormUtil.SetDefaultButton((Button)GridViewSearchPanel1.FindControl("cmdSearch"));
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
string urlParams = string.Format("TimeSheetId={0}", GridView1.SelectedDataKey.Values[0]);
Response.Redirect("TimeSheetsEdit.aspx?" + urlParams, true);
}
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) {
}
}
=======================================================
TimeSheet.aspx
=======================================================
<%# Page Language="C#" Theme="Default" MasterPageFile="~/MasterPages/admin.master" AutoEventWireup="true" CodeFile="TimeSheets.aspx.cs" Inherits="TimeSheets" Title="TimeSheets List" %>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">Time Sheets List</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<data:GridViewSearchPanel ID="GridViewSearchPanel1" runat="server" GridViewControlID="GridView1" PersistenceMethod="Session" />
<br />
<data:EntityGridView ID="GridView1" runat="server"
AutoGenerateColumns="False"
OnSelectedIndexChanged="GridView1_SelectedIndexChanged"
DataSourceID="TimeSheetsDataSource"
DataKeyNames="TimeSheetId"
AllowMultiColumnSorting="false"
DefaultSortColumnName=""
DefaultSortDirection="Ascending"
ExcelExportFileName="Export_TimeSheets.xls" onrowcommand="GridView1_RowCommand"
>
<Columns>
<asp:CommandField ShowSelectButton="True" ShowEditButton="True" />
<asp:BoundField DataField="TimeSheetId" HeaderText="Time Sheet Id" SortExpression="[TimeSheetID]" ReadOnly="True" />
<asp:BoundField DataField="TimeSheetTitle" HeaderText="Time Sheet Title" SortExpression="[TimeSheetTitle]" />
<asp:BoundField DataField="StartDate" DataFormatString="{0:d}" HtmlEncode="False" HeaderText="Start Date" SortExpression="[StartDate]" />
<asp:BoundField DataField="EndDate" DataFormatString="{0:d}" HtmlEncode="False" HeaderText="End Date" SortExpression="[EndDate]" />
<asp:BoundField DataField="DateOfCreation" DataFormatString="{0:d}" HtmlEncode="False" HeaderText="Date Of Creation" SortExpression="[DateOfCreation]" />
<data:BoundRadioButtonField DataField="Locked" HeaderText="Locked" SortExpression="[Locked]" />
<asp:BoundField DataField="ReviewedBy" HeaderText="Reviewed By" SortExpression="[ReviewedBy]" />
<data:HyperLinkField HeaderText="Employee Id" DataNavigateUrlFormatString="EmployeesEdit.aspx?EmployeeId={0}" DataNavigateUrlFields="EmployeeId" DataContainer="EmployeeIdSource" DataTextField="LastName" />
</Columns>
<EmptyDataTemplate>
<b>No TimeSheets Found!</b>
</EmptyDataTemplate>
</data:EntityGridView>
<asp:GridView ID="GridView2" runat="server">
</asp:GridView>
<br />
<asp:Button runat="server" ID="btnTimeSheets" OnClientClick="javascript:location.href='TimeSheetsEdit.aspx'; return false;" Text="Add New"></asp:Button>
<data:TimeSheetsDataSource ID="TimeSheetsDataSource" runat="server"
SelectMethod="GetPaged"
EnablePaging="True"
EnableSorting="True"
EnableDeepLoad="True"
>
<DeepLoadProperties Method="IncludeChildren" Recursive="False">
<Types>
<data:TimeSheetsProperty Name="Employees"/>
<%--<data:TimeSheetsProperty Name="TimeSheetDetailsCollection" />--%>
</Types>
</DeepLoadProperties>
<Parameters>
<data:CustomParameter Name="WhereClause" Value="" ConvertEmptyStringToNull="false" />
<data:CustomParameter Name="OrderByClause" Value="" ConvertEmptyStringToNull="false" />
<asp:ControlParameter Name="PageIndex" ControlID="GridView1" PropertyName="PageIndex" Type="Int32" />
<asp:ControlParameter Name="PageSize" ControlID="GridView1" PropertyName="PageSize" Type="Int32" />
<data:CustomParameter Name="RecordCount" Value="0" Type="Int32" />
</Parameters>
</data:TimeSheetsDataSource>
</asp:Content>
Problem can be that GridView1 is not automatically added in designer.cs file. If that is case add it in designer manually.
Assuming a WebSite project verify that when building it you do not get Warnings like:
Generation of designer file failed: [Failure Reason]
It seems that you're not registering the custom control EntityGridView. See the Register directive to see how you can do it.
I've had this problem before when I've 'added' an existing file (.aspx + .aspx.cs) to a project and the designer file hasn't updated itself. I've tried many/all of the things written here, but I find that creating a new file, copying the code-front code in, then the code-behind and then rebuilding essentially does the trick. Yes, it's a pain in the * depending on the size of the file(s) you're working with, but this typically happens when I want to quickly test some demo code I've come across (some new project etc.) and throw it into my local VS.
It is nested, so some things don't happen automatically.
You might have to manually add it to the designer, or else (in VB) explicitly use the handles keyword or (in C#) explicitly wire up with "+=" operator.
Make sure all events or explicitly stated in the control mark-up
Since I see you list the event explicitly, I'd check the designer.
I had this same problem in Visual Studio 2010. The design.cs file was correctly generated. I closed Visual Studio, and reopened it. This resolved this issue for me (after much frustration).
I don't know if this will help, but I've been fighting with a similar situation.
The situation: I have included some code from the modified some of the templated asp.net web project into my project - specifically the login markup. For some reason, one of the "UserName" Textbox control refuses to be recognized in the designer. Strangely enough, the "UserNameLabel" control on the next line of markup is recognized:
<%# Page Language="C#" AutoEventWireup="True" CodeBehind="Logon.aspx.cs" MasterPageFile="~/Site.master" Inherits="SimpleWebApp.Logon" %>
<asp:Content ID="LogonRegister" ContentPlaceHolderID="MainContent" runat="server">
<div></div>
<table align="center">
<tr>
<td valign="top">
*<asp:TextBox ID="TextBox1" runat="server" CssClass="textEntry"></asp:TextBox>*
<asp:Login ID="LoginUser" runat="server" EnableViewState="true" RenderOuterTable="false">
<LayoutTemplate>
<span class="failureNotification">
<asp:Literal ID="FailureText" runat="server"></asp:Literal>
</span>
<asp:ValidationSummary ID="LoginUserValidationSummary" runat="server" CssClass="failureNotification"/>
<div class="accountInfo">
<fieldset class="login">
<legend>Log In</legend>
<p>
**<asp:Label ID="lblUserNameLabel" runat="server">Username:</asp:Label>**
***<asp:TextBox ID="UserName" runat="server" CssClass="textEntry"></asp:TextBox>***
</p>
...
What I've tried:
I've restarted VWD 2010,
deleted the designer file and recreated it through converting the page to a web application
changed the name of the Textbox,
deleted and recreated the Textbox.
I decided to experiment a little, and discovered that adding a typical textbox just outside the asp:Login tag is recognized, while adding it just inside that tag leaves it unrecognized in the designer.
Figured this might help myself or someone else to piece together what might be going on.
Anyone have any idea what might cause this behavior around the asp:Login tag?
For closely related answers, visit a slightly similar question, How do you force Visual Studio to regenerate the .designer files for aspx/ascx files?.
#sameer: I'd be interested to hear if you tried to replace CodeFile="TimeSheets.aspx.cs" with CodeBehind="TimeSheets.aspx.cs" before converting the project.
I know this is an old thread, but I just struggled with an issue similar to this. After a couple of days, I figured out that I had a backup copy of the problem page and code behind in my project. I kept getting the error "does not exist in the current context" at compile time on objects placed on the new page, even though intellisense recognized them. I guess VS was getting confused because of the duplicate pages in the default namespace. Once I got rid of the backup, I magically stopped getting the errors.
I had the same problem, none of the solutions worked for me. I figured out without wasting too much time, that many of the ASPX pages in the Admin section were being given the same class name as the entities in the project entity files. Also, each of the pages listed the Entities namespace causing conflicts since after adding the entity namespace in the using directives, there were namespace conflicts. I went through and added "Page" to each of the ASPX page, recompiled and everything worked fine.
I know this thread has already been answered, but I wanted to include this description in case there are others that have this same problem and none of the above solutions worked, to give them something else that might be the issue.
I had 21 pages to change in my project, here is an example using the UserEntity and the Admin/UserEntity.aspx:
in UsersEntity.aspx front side aspx page, changed:
<%# Page Language="C#"
Theme="Default"
MasterPageFile="~/MasterPages/admin.master"
AutoEventWireup="true"
Inherits="UsersEntity"
Title="UsersEntity"
Codebehind="UsersEntity.aspx.cs"
%>
to:
<%# Page Language="C#"
Theme="Default"
MasterPageFile="~/MasterPages/admin.master"
AutoEventWireup="true"
Inherits="UsersEntityPage"
Title="UsersEntity"
Codebehind="UsersEntity.aspx.cs"
%>
in the UsersEntity.aspx.cs code behind, I changed:
public partial class UsersEntity : System.Web.UI.Page
to:
public partial class UsersEntityEntityPage : System.Web.UI.Page
and in the UsersEntity.aspx.designer.cs (Designer Page):
That page got automatically changed when I changed the code behind page to:
public partial class UsersEntityPage {
I did that for each of the other offending pages, which were all of them except for the "Edit" pages.
-- I guess I could have just removed the using directive to the Entity name space, but I really want to be able to have access to that in my pages, plus I think it is ungood for the page classes to have the exact same name as my entity classes. It causes confusion to me to have it like that.
copy the _.aspx file code and paste it on the _.aspx.cs page.
if it is not then import namespaces all the way top.
<%# Page Language="C#" AutoEventWireup="true" %> <%# Import
Namespace="System.Data" %> <%# Import
Namespace="System.Data.SqlClient" %>
I found that there was an incorrect file reference name in the designer.cs file. It was the code filename with a 1 added to the end. I removed the 1 and the code ran without error. Prior to this I deleted and rebuilt the designer file without resolution.
The easiest way is to:
Delete the designer file (YourFilename.aspx.designer.cs)
Select the ASPX file in Solution Explorer
Under Projects menu look for the item "Convert to Web Application" and click on it. Click Yes on the dialog window.
Open up the newly created designer file and make sure the namespace matches the namespace on the primary aspx.cs file (VERY IMPORTANT)
Close the designer file.
Save the solution. Close it and then reopen.

ASP.NET Controls are not coming in Code-behind IntelliSense

I am having an aspx page where I have added one asp.net text box control with ID and RUNAT attribute. But in Code-behind I am not seeing this control's name in the intellisense.
My page directive in aspx is as follows
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="MyProject_UI._Default" %>
I am using VS 2008. Any idea how to get rid of this?
Try using CodeFile instead of CodeBehind. The latter is a hold-over from .NET 1.1.
Also, make sure the namespaces match up between the markup and the code. Do a test compile to be sure.
I have seen this on occasion when I edit a page. When it happens to me, I close the files and open them again and it seems to fix itself.
This will happen if you are trying to include your control in LayoutTemplate. For example if you are using an asp label in a login control you have converted to a LayoutTemplate.
<asp:Login ID="userLogin" runat="server">
<LayoutTemplate>
<!--Username and password controls-->
<asp:Button ID="btnLogin" CommandName="Login" runat="server" Text="Login" />
<asp:Label ID="lblAlert" runat="server"></asp:Label>
</LayoutTemplate>
So your lblAlert will not show up on the code behind take it out of the layouttemplate or use a loop to find the control within the layout object.
var mylabel = (Label)userLogin.FindControl("lblAlert");

Resources