ASP.NET Management Not Available in CodeBehind

I am dragging a Label control on my ABC.ASPX page. It compiles correctly. But control ( Label2 ) is not available for ABC.ASPX.cs code for assigning values.

What is permission?

 <%@ Page language="c#" CodeBehind="ABC.aspx.cs" AutoEventWireup="false" %> <asp:Label ID="Label2" runat="server" Font-Bold="True"></asp:Label> 
+6
source share
5 answers

You are probably missing an entry for this in the designer.cs file. You can add something like this to the file:

 protected global::System.Web.UI.WebControls.Label Label2; 

Or delete the designer.cs file, right-click the parent aspx file and select Convert to Web Application. This should recreate the designer.cs file with all the relevant entries.

+9
source

You may need to add Inherits="XXX.ABC" to your Page Directive, where XXX is your root namespace. Also, I assume that you called your ABC class to match ABC.aspx.cs.

+2
source

Try deleting the control, saving the file, adding the control again and saving the file again. The problem is probably in your * .designer.cs file, this approach should restore it.

+1
source

After creating the custom component, I wanted to test it on the CalendarTest page. I, too, could not access the user component through the "For" code. I did not find the solution online, but through the trial version and the error I fixed it with the following steps:

1) in an aspx file, <% @Page ... requires "CodeFile =" instead of "src =" to point to the code behind the file

2) in the code behind the aspx.cs file, I need to replace "public class CalendarTest" with "public partial class CalendarTest"

0
source

Right click on the project, then select Convert to Web Application

0
source

Source: https://habr.com/ru/post/912797/


All Articles