Element 'RadGrid' is not a known element - asp.net

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.

Related

How to find the source of a rogue script call in WebForms

I'm hunting down a weird error in a WebForms project, where I can't find the source of a second jQuery reference.
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-1.10.2.min.js",
//additional entries omitted
));
Now this bundle is called in my master page file:
<asp:PlaceHolder runat="server">
<%: Scripts.Render("~/bundles/jquery") %>
<%: Styles.Render("...") %>
</asp:PlaceHolder>
As long as the user stays in the root folder of the webpage (www.domain.com/page) evertyhing works fine. Unfortunately, when the user gets redirected to a aspx page located in a subfolder (www.domain.com/subfolder/someotherpage) the following error appears:
Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:53078/Scripts/jquery-1.10.2.js
I've searched the whole solution, but can't find the part, where this originates from.
Looking at the rendered source code I see this:
<body>
<script src="../Scripts/jquery-1.10.2.js" type="text/javascript"></script>
</body>
Now this does not look like the script tags rendered by the bundling, which are located in the head. Given the position of the script tag, this should originate from the master page file, but I can't put my finger on it:
<head runat="server">
<asp:PlaceHolder runat="server">
<%: Scripts.Render("~/bundles/jquery") %>
<%: Styles.Render("~/bundles/Stylesheets") %>
</asp:PlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<telerik:RadScriptManager runat="server" EnableEmbeddedjQuery="false">
<Scripts>
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryExternal.js" />
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryPlugins.js" />
</Scripts>
</telerik:RadScriptManager>
<%: Scripts.Render("~/bundles/UiEffects") %>
</body>
Before you suggest it: I've tried replacing the RadScriptManager with a vanilla asp:ScriptManager, but to no avail.
Is it possible to determine, from which line of code in an asp.net web project the script refernce originates, so I can eliminate it?
Since, there was no obvious plain text reference to jQuery-1.10.2.js, it had to be either a bug in Telerik or a referenced assembly.
I did not check the installed Nuget packages. There was one installed, which was automatically registering jQuery with the ScriptManager:
http://www.nuget.org/packages/AspNet.ScriptManager.jQuery/1.10.2
If you have this installed, you must not reference jQuery again, or you might run into $(...).functionName() is not a function errors.
So, there are 2 possible solutions to this problem:
Re-install this package / update this package and remove every other reference to jQuery in your master page file or
Remove this NuGet package with uninstall-package AspNet.ScriptManager.jQuery -project xxx

Custom UserControl is not registering in 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.

ToolkitScriptManager is not a known element

I have a website in which I am using the AJAX Accordion Pane. In order to fully use the RequireOpenedPane="False" I need to have the ToolkitScriptManager added to the site.
I understand all of this but there's an issue. Visual Studio 2012 says the ToolkitScriptManager is not a known element
I have
<add tagPrefix="asp" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" />
in the web.config file, and
<asp:Accordion ID="Accordion1" runat="server" CssClass="accordion" SelectedIndex="-1" HeaderCssClass="accordionHeader" HeaderSelectedCssClass="accordionHeaderSelected" ContentCssClass="accordionContent" RequireOpenedPane="False" FramesPerSecond="25" Width="820px" >
works with no errors. But
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></asp:ToolkitScriptManager>
does not.
Here's the funny thing, if I remove the ToolkitScriptManager from the page, it'll load the Accordion, however, not all functionality will be working (for example, clicking an accordion header does not select the header, it just expands the header, but does not show as "Selected").
The page DOES have a MasterPage as well, the ToolkitScriptManager is inside the ContentPlaceHolder for the body. (it's actually right above the Accordion control). Why is this doing this, and how can I fix it?
<%# Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="page.aspx.cs" Inherits="page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeaderContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MenuContent" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
<h1 align="center">Classes</h1>
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></asp:ToolkitScriptManager>
<asp:Accordion ID="Accordion1" runat="server" CssClass="accordion" SelectedIndex="-1" HeaderCssClass="accordionHeader" HeaderSelectedCssClass="accordionHeaderSelected" ContentCssClass="accordionContent" RequireOpenedPane="False" FramesPerSecond="25" Width="820px" >
<Panes>
<asp:AccordionPane runat="server" ID="AccordionPane0">`
Found solution:
Apparently the AjaxControlToolkit obtained from using the NuGet installer on Visual Studio 2010 does NOT have the ToolkitScriptManager. I had to remove the DLL installed from NuGet and install my own DLL which did include the ToolkitScriptManager.
I'm not sure why the NuGet version does not contain the ToolkitScriptManager.
On top of your solution user1760784, others may ALSO need to setup IIS first and import their app in. Once the app is fully setup in IIS then try to run it. It should work. With this process done my issue was resolved.
Please note this is true for both test IIS and live/production IIS. Although as we all know it's always safer to test off live boxes.
Why does it only resolve when testing on IIS?
I don't really know. However I believe it could because of http/browser issues. Maybe you smarter folks can let us know on this point.
Enjoy!

CollapsiblePanelExtender A potentially dangerous Request.Form value was detected from the client

I am encountering this error whenever the button is clicked to collapse/expand the panel.
Error: CollapsiblePanelExtender A potentially dangerous Request.Form value was detected from the client.
Can someone tell me what I did wrong and what is causing this?
<asp:Button ID="Button1" runat="server" Text="Button" />
<ajaxToolkit:CollapsiblePanelExtender
TargetControlID="testPanel"
ID="CollapsiblePanelExtender1"
runat="server"
ExpandControlid="Button1"
CollapseControlID="Button1"
Collapsed="False"
ExpandDirection="Vertical"
AutoCollapse="false"
AutoExpand="false">
</ajaxToolkit:CollapsiblePanelExtender>
<asp:Panel ID="testPanel" runat="server">
stuff here
</asp:Panel>
Put validateRequest="false" in your page directive or web.config file.
Adding Cross-Site Scripting Protection to ASP.NET
for example if you already have:
<%# Page Language="vb" AutoEventWireup="false" Codebehind="MyForm.aspx.vb" Inherits="Proj.MyForm"%>
then this should become:
<%# Page Language="vb" AutoEventWireup="false" Codebehind="MyForm.aspx.vb" Inherits="Proj.MyForm" ValidateRequest="false"%>
Note:
If you are using .NET 4 then you will need to add requestValidationMode="2.0" to the httpRuntime configuration section of the web.config file. For example:
<httpRuntime requestValidationMode="2.0"/>
If you don't already have a httpRuntime section in the web.config file then this goes inside the section.
Thanks

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.

Resources