Solved

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

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

The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

Question has a verified solution.

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

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 …
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

830 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