Solved

Basic question, Changes on code behind (.aspx.cs) file dosen't effect

Posted on 2009-05-15
3
401 Views
Last Modified: 2013-11-26
Hi There,
This should be a very basic question.I just started working on an existing Visual Studio Web project, and I have to do some changes on the site.
The Web project written by ASP.NET 2.0 and C#, and I opened it with Visual Studio 2008(I didn't upgrade to higher ASP.NET).
The code is working, I can Built and Publish it.  I started do some changes on the .aspx files and re-Build and re-Publish it, it also works fine, but now I need to do some changes on the code behind (.aspx.cs files), I do the changes and re-Built the project/page but it seams my changes just ignored. I even add some garbage to some of the .aspx.cs pages and save it and then re-Build it, no error, it says it built successfully. It seems I'm missing something and it gets the code behind from somewhere else??  
What should I do to force it to compile the code behind?
Thanks  


   

0
Comment
Question by:esasan
  • 2
3 Comments
 
LVL 20

Expert Comment

by:ddayx10
ID: 24400093
Show me this line(should be at the top of the .aspx page):
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

And the code behind (doesnt have to be all of it, but at least the class and some of the code you changed):

EX:
public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
         //CODE I CHANGED
    }
}

ALSO, do you have a BIN folder in your project, and is it full of .dll's? If so it's very possible the project is working from the existing .dll's and ignoring your code behind. When you publish it should make new .dll's and these would need to be placed into your projects bin folder. Or you can remove the .dll's from the BIN folder (dont delete them just move them out of the project for a test), and see if your changes begin to take effect.

dday
0
 

Author Comment

by:esasan
ID: 24400365
Hi dday,
Answer to your questions:
1.  .aspx starts with:
<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Site.Master" CodeBehind="CL.aspx.cs" Inherits="ProjectName.Admin.CL" %>

2. Code behind that I changed(I changed lot`s of them like):
 public partial class ConfigList : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindGrid();;;;XYZ                            // (I added those garbage ;;;XYZ as an example)
            }
        }
Then I Re-Built the page, no error it works just fine.

3. ALSO, do you have a BIN folder in your project ....
Yes, there is a bin folder with: 2 .dll for AJAX, 2 file with the name same as project name one ProjectName.dll and second ProjectName.pdb,  also:
MetaBuilders.WebControls.RowSelectorColumn.dll and System.Web.Extensions.dll.
I tried to remove the ones with the ProjectName. , but if I remove them then when I try to Built I get error: ProjectName.data (or Some thing) is Missing.

Thanks  



 
0
 
LVL 20

Accepted Solution

by:
ddayx10 earned 500 total points
ID: 24400516
OK so look at the "Inherits" from the first line, and teh classname "ConfigList" on #2.

If the .aspx page was pointing to the code behind you posted then the .aspx inherits would read:
Inherits="ConfigList"

Instead it is pointing to a namespace.class that is likely in either the app_code folder or pre-compiled into .dll's in the BIN directory.

The simple answer is to change the inherits attribute on the .aspx page to point to the class of the code behind associated with it.

This may not be a problem if you don't care about what was previously written so much, but alas you probably do. So you are going to have to find that class file and make sure it's compiling its .dll into the BIN directory.

I could be off base here but I stronly suspect it's something like this. If you cant find the class it might help you to press Ctrl-Shift-F and search for the namespace.class in your entire solution.

Good Luck. I doubt I can offer much more assistance than this, but someone else may catch on and have some ideas for you :)

dday
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now