[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 138
  • Last Modified:

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.
0
-Dman100-
Asked:
-Dman100-
  • 6
  • 3
1 Solution
 
JimBrandleyCommented:
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
0
 
JimBrandleyCommented:
For the second part, do you mean that the new method you add doesn't show up in intellisense later?

Jim
0
 
-Dman100-Author Commented:
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?
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
-Dman100-Author Commented:
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?
0
 
JimBrandleyCommented:
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
0
 
JimBrandleyCommented:
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...
0
 
JimBrandleyCommented:
I was not able to locate any others.

Jim
0
 
-Dman100-Author Commented:
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?
0
 
JimBrandleyCommented:
I think I found a way.
1. Create backups of the files!
2. Open one of their source files.
3. Set your editor (as earlier) to save spaces - tab size = 2, indent size = 2.
4. Select all lines in the file.
5. Select Edit/Advanced/Tabify Selected Lines. (Converts initial space pairs to tabs).
6. Set editor for tab size = 4, indent size = 4.
7. Select Edit/Advanced/Untabify Selected Lines.
8. Save the file.
Repeat steps 2 - 8 for remaining files.

Jim
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.

  • 6
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now