?
Solved

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

Posted on 2009-05-15
3
Medium Priority
?
419 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 1500 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
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…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

765 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