Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 552 Vote(s) - 3.51 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Asp.net controls are not accessible in code behind

#11
Use `CodeBehind` attribute instead of `CodeFile` attribute of Page tag.

Eg:

<%@ Control Language="C#" AutoEventWireup="true" **CodeBehind**="Results.ascx.cs" Inherits="MyApp.Results" %>
Reply

#12
This happened to me in a website project in VS2010, but as I'm part of a larger team, I don't have the option to convert to Web Application as Domenic suggested.

It turns out it was because I had switched my default editor for ASPX files to "HTML Editor" instead of "Web Form Editor". I did this because intellisense was killing my computer whenever I opened an ASPX file. When I right clicked on this page to "Open With..." the "Web Form Editor", and added the controls again, it worked perfectly and they're now available in the code behind file.
Reply

#13
I had the same issue when 2 ASP Pages were using the same Code Behind file (It was ASP.NET Web Site project in Visual Studio 2013, not an ASP.NET Web Application). I have solved the problem by changing it to use different Code Behind files for each page.
Reply

#14
If you're experiencing this issue in VS2013 in a Website (as opposed to a Web Application) and have more than one aspx file sharing a codebehind then you need to make sure that ALL the aspx files have exactly the same collection of controls.

In previous versions of Visual Studio this wasn't an issue but it looks like VS2013 has tightened up.

I hope this helps someone - I only spotted it thanks to Sergey's comment above.
Reply

#15
I have the same problem. I found the solution by removing "**PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI" TagPrefix="asp" %>**" from aspx page and it works normal now.
Reply

#16
If your trying to access the tags from your own built in method on the back-end make sure that you don't make this method static - otherwise you wont have access to these tags...

<p #id="myTag" runat="server">...</p>

private static void myMethod(){
myTag.InnerText = "Hello" //You will not have access to this tag
}

private void myMethod(){
myTag.InnerText = "Hello"; //You have access to tags
}
Reply

#17
Faced a similar problem because the controls were either within the:
"LoginView" or "AnonymousTemplate" and Viewstatemode was Disabled

Resolved by moving the Asp controls outside these tag elements
Reply

#18
Possible reasons:

- id mismatch.
- runat="server" not present in the control at .aspx file.

The solution that I found, apart from correcting the above, is to rebuild the project:

One more thing you need to take care is, before rebuild, close the designer file.
Reply

#19
I had a similar problem. I faced this problem when I tried to rename the aspx file. In my case, the class name was not updated from UpdateRecords to ModifyRecords when I renamed the aspx file to ModifyRecords. Hence none of the ASP.NET controls were accessible from the code behind.

**Code behind before renaming:**

public partial class UpdateRecords : System.Web.UI.Page

**Code behind after renaming:**

public partial class ModifyRecords : System.Web.UI.Page

If you try to rename aspx file or copy-paste from different file, just make sure, the class name is updated.
Reply

#20
I also had a similar problem in the past. As you have mentioned that the project was **previously built by someone else**, So it must be coded in VB based coding and you can check that in web.config compilation details. Try copying the aspx page content onto your newly created C# aspx page and paste the code as well it will work.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through