tags:

views:

610

answers:

6

Recenty I installed resharper 4.5, It has cool new feature of checking naming convention, but with this there has been lots of warning message popping up in my aspx file suggesting to prefix all web control name with "_" as it is member field, would like to know what naming convention you prefer for web control and do you prefix control name with "_"

A: 

Hungarian notation is generally frowned upon now, however when you have user controls and data entities that hold the same data, it can be useful to prefix the user controls.

I prefix all user controls with ux. I used to go with lblLabel, txtTextbox, but if you ever change one to another, it causes a lot of pain.

ck
+1  A: 

This question has been asked in many different forms here on SO but not specifically about web controls. Yet the common wisdom remains:

It doesn't matter what you choose as long as you use it consistently.

Andrew Hare
A downvote without a comment is is not very constructive. If I said something wrong please comment so that I can address it.
Andrew Hare
+2  A: 

I prefix all my UI elements with "ux" for user experience. I prefer this to txt, lbl, etc. because it makes it easy to change the control type. As far as ReSharper goes, I turned off that naming convention check while working in ASP.NET.

Jamie Ide
+1 for remembering that you can always turn these features off ;)
Zhaph - Ben Duguid
A: 

hi, you can customize resharper to turn on/off or add your own rules to it.

on the other side, for me it does not really matter, what matter is consistency, what i mean is if you wanna take a method like prefixing your UI elements, Privates then follow it all over the site.

it is your choice, your strategy :)

+1  A: 

ReSharper 4.5 allows you to add multiple naming styles for each kind of entity.

So, just as you can add one that specifies UpperCamelCase with a prefix of "_" you can specify the same with a prefix of txt, lbl, cbo, etc. This is, however, kind of laborious and doesn't allow you to restrict each prefix to a specific type of web control.

I guess that this is one thing that the ReSharper team have not yet addressed, certainly they don't mention such features in their documentation.

Edit

Definitely not currently supported - http://www.jetbrains.net/devnet/thread/281015

Richard Ev
A: 

You can force ReSharper to interrogate event names globally or specifically for C# or VB. Check out my answer in the following post:

http://stackoverflow.com/questions/2994774/resharper-conventions-for-names-of-event-handlers

dnorthut