Results 1 to 2 of 2

Thread: WebControl Naming Guidelines and FxCop

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    Fort Collins, CO
    Posts
    366

    WebControl Naming Guidelines and FxCop

    So I was doing some code reviews, refactoring, etc and decided to try out fxcop. Not sure how many of you have used it but I like it.

    Except for one part. If I have a label used for displaying, say, someone's first name, I'll give it an ID of lblFirstName. Well, out of the box, fxcop complained about the lbl, saying that 1, it's an unknown word, and 2, since i've declared it as a protected method, it should be Pascal-cased like this LblFirstName; oh and 3, it suggests that it might be better to expose the label as a property(ie. declare the control as private and expose it through a property). Anywho, so ok, I could fix the errors and yay, I pass the fxcop test. But that got me thinkin, if lblFirstName is incorrect, then what's correct(that is, with respect to naming web controls)? Should it be FirstNameLabel?

    How do you all name your controls? like a label for example. I couldn't find naming guidelines for controls in the msdn library. Here's how I usually name some other ones:

    dgAuthors (DataGrid)
    txtFirstName (TextBox)
    btnSave (Button)
    valreqFirstName (RequiredFieldValidator, sometimes use rfv)
    ddlStateList (DropDownList)
    lbCities (ListBox)
    rblUserType (RadioButtonList)
    pnlUserInfo (Panel)

  2. #2
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    I use lblFirstName...

    many people probably do... I don't know anything about fxcop, but its really silly they would mention something like that. Either way, it doesn't affect performance one bit... and its really superfluous fluff to make their program look good.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width