Solved

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

Posted on 2009-05-15
3
395 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

747 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

13 Experts available now in Live!

Get 1:1 Help Now