Link to home
Start Free TrialLog in
Avatar of -Dman100-
-Dman100-Flag for United States of America

asked on

strange problem occuring in code-behind

I'm encountering a very strange problem in Visual Studio 2005 in my code-behind pages.  when I try and add new methods the code does not line up in the normal code structure.

The problem occurs with some code that a 3rd party company developed.  This does happen if I add a new  project or work with an existing code I have developed.

The problem is hard to describe.  I'm not sure how to explain what is happening.

For example, take the Page Load method.  It would be lined up like this:

protected void Page_Load(object sender, EventArgs e)
{
     // Code goes here
}

  protected SomeMethod()
  {
        // The code is not lined up with the above method
        //  It is aligned two spaces to the right
       // ??????? what is going on?
  }

If I try and add a new method, I enter a line break, but the cursor lines up 2 spaces further in, like invisible comments have been added or something like that?  It is very strange.  The method isn't recognized in the intellisense.

So, I have to backspace each line of code that I add so it falls into the normal code structure alignment.  Then the method will be recognized.

Does anyone know what is going on?  Can anyone help?  I'm pulling my hair out over this.

Any help is appreciated.
Thanks.
Avatar of JimBrandley
JimBrandley
Flag of United States of America image

I suspect the problem may be in the setting that controls Tabs-vs-Spaces. Take a look at:
Tools/Options/Text Editor/C#/Tabs.

My guess is that the third party used a different setting than you do.

Jim
For the second part, do you mean that the new method you add doesn't show up in intellisense later?

Jim
Avatar of -Dman100-

ASKER

Hi Jim,

Thanks for replying to my post.  I checked the settings that controls Tabs-vs-Spaces.  I have the default settings...i.e. Indenting is set to smart and Tab has both Tab Size and Indent size set to 4 and the insert spaces radio button is selected.

I added their code to a project I setup in my soluttion.  The project builds and runs fine, but I have the problem when I try and add new code?

The code will show up in intellisense when I use the backspace key to line up each line of code into the normal code structure.  Obviously, I don't want to have to backspace each line of code that I add everytime to get it to work.  That would be crazy.

I'm not sure how I need to modify my settings to correct this if it is the Tabs settings?
Hi Jim,

As a follow-up.  If it is the tab settings, which it could be because it looks they have they have their settings set to 2 spaces, where I have the default set to 2 spaces.

so, how can I globally change the settings for all their pages to sync with my settings of 4 spaces?
1. I do not yet know how to go back and change theirs yet, but will continue to search.

2. If you change the default spacing to match theirs(2), then add a new method, does it now show up in intellisense without the backspacing?

Jim
I found some references to Intellisense malfunctioning if the .suo file was corrupted. You can try deleting that file to see if it has any impact on your problem. I will search some more...
I was not able to locate any others.

Jim
Hi Jim,

Yes, if I change my default settings to match their tab spacing (2) then intellisense recognizes the methods that I add and there is no problem.

Now, I just need to figure out how to globally change their settings so it matches up with mine?
ASKER CERTIFIED SOLUTION
Avatar of JimBrandley
JimBrandley
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial