473,326 Members | 2,076 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Naming conventions for ASP.NET objects?

=B=
Hi,

I was wondering if anyone has any opinions on naming conventions for
ASP.NET objects?

Up until now I've been using txtThis for Text Boxes, ddlThat for
DropDownList, etc because I think it helps the readability. When
working with a code-behind file you can tell what type of object
you're accessing. Of couse, this Hungarian notation is frowned upon
by the Microsoft guidelines for classes at
http://msdn.microsoft.com/library/de...guidelines.asp
and FXCop complains about 'txt' not being a word, etc.

How does everyone else name their web controls?

Thanks,

B.
Nov 18 '05 #1
4 5678
That is how I do it also.

"=B=" <br*************@yahoo.co.uk> wrote in message
news:46*************************@posting.google.co m...
Hi,

I was wondering if anyone has any opinions on naming conventions for
ASP.NET objects?

Up until now I've been using txtThis for Text Boxes, ddlThat for
DropDownList, etc because I think it helps the readability. When
working with a code-behind file you can tell what type of object
you're accessing. Of couse, this Hungarian notation is frowned upon
by the Microsoft guidelines for classes at
http://msdn.microsoft.com/library/de...guidelines.asp and FXCop complains about 'txt' not being a word, etc.

How does everyone else name their web controls?

Thanks,

B.

Nov 18 '05 #2
When you read that MS frowns on Hungarian notation for classes, they are
talking about just that the class name, not the instance name.

I think you will find that the use of naming notations with controls is
still very much alive (remember a control that you use on your form is not
the class (TextBox), but an instance of a class (txtUser).
"=B=" <br*************@yahoo.co.uk> wrote in message
news:46*************************@posting.google.co m...
Hi,

I was wondering if anyone has any opinions on naming conventions for
ASP.NET objects?

Up until now I've been using txtThis for Text Boxes, ddlThat for
DropDownList, etc because I think it helps the readability. When
working with a code-behind file you can tell what type of object
you're accessing. Of couse, this Hungarian notation is frowned upon
by the Microsoft guidelines for classes at
http://msdn.microsoft.com/library/de...guidelines.asp
and FXCop complains about 'txt' not being a word, etc.

How does everyone else name their web controls?

Thanks,

B.

Nov 18 '05 #3
I follow FxCop (and therefore microsoft guidelines). Hungarian notation is
frowned upon...and, unlike what Scott said, it's not just for class names
but everything (instances, fields, proeprties...). The reasoning behind
this, as I understand it is two-fold:

[a] - leverage your tool's ability to know what type it is (ie, buy vs.net
*$$$$*)
[b] - a far better reason is that your code should be properly refactored
and as such, should never be so complex that someone needs to know what type
of variable is. In other words, readability comes from proper design and
not any metadata you can stuff into a variable's name.

if you name your variables That and This though, hungarian notation might
not be such a bad idea :P

Karl

"=B=" <br*************@yahoo.co.uk> wrote in message
news:46*************************@posting.google.co m...
Hi,

I was wondering if anyone has any opinions on naming conventions for
ASP.NET objects?

Up until now I've been using txtThis for Text Boxes, ddlThat for
DropDownList, etc because I think it helps the readability. When
working with a code-behind file you can tell what type of object
you're accessing. Of couse, this Hungarian notation is frowned upon
by the Microsoft guidelines for classes at
http://msdn.microsoft.com/library/de...guidelines.asp and FXCop complains about 'txt' not being a word, etc.

How does everyone else name their web controls?

Thanks,

B.

Nov 18 '05 #4
=B=
Thanks for all the responses, guys. And Karl, in retrospect maybe
those variable names weren't the best examples... :D

I do actually use VS.NET. It's just that coming from an Interdev
background onto ASP.NET I guess it's a force of habit more than
anything else to use prefixes for control IDs. Should I be using
camel case instead?

A problem with this though is that if I have a TextBox control called
'userId' and perhaps I need String which I use to hold the contents of
this TextBox, I can see situations where following Microsoft's
guidelines (or what I perceive to be them) on this issue could cause
confusion. Distinguishing between the control and the string variable
by giving them different variable names, e.g. calling the TextBox
userIdTextBox, I'm still storing the object type in the variable name.

I'm studying for my 70-305 exam and it doesn't help matters that all
the examples in the MS book so far seem to use Hungarian notation!

B.
"Karl" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in message news:<#l**************@TK2MSFTNGP15.phx.gbl>...
I follow FxCop (and therefore microsoft guidelines). Hungarian notation is
frowned upon...and, unlike what Scott said, it's not just for class names
but everything (instances, fields, proeprties...). The reasoning behind
this, as I understand it is two-fold:

[a] - leverage your tool's ability to know what type it is (ie, buy vs.net
*$$$$*)
[b] - a far better reason is that your code should be properly refactored
and as such, should never be so complex that someone needs to know what type
of variable is. In other words, readability comes from proper design and
not any metadata you can stuff into a variable's name.

if you name your variables That and This though, hungarian notation might
not be such a bad idea :P

Karl

"=B=" <br*************@yahoo.co.uk> wrote in message
news:46*************************@posting.google.co m...
Hi,

I was wondering if anyone has any opinions on naming conventions for
ASP.NET objects?

Up until now I've been using txtThis for Text Boxes, ddlThat for
DropDownList, etc because I think it helps the readability. When
working with a code-behind file you can tell what type of object
you're accessing. Of couse, this Hungarian notation is frowned upon
by the Microsoft guidelines for classes at

http://msdn.microsoft.com/library/de...guidelines.asp
and FXCop complains about 'txt' not being a word, etc.

How does everyone else name their web controls?

Thanks,

B.

Nov 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: clintonG | last post by:
Does the use of DTD, XML Schema and similar constructs adopt the use of C# naming conventions? If so how do I make the distinction of how to apply C# conventions with XML elements, attributes and...
5
by: rastaman | last post by:
Hi all, I know of the existence of Object Naming Conventions for Visual Basic 6. Now I'm reading some books about VB .NET, but the names used for the objects are button1, picturebox1, etc. I...
4
by: kd | last post by:
Hi All, What is the naming convention for objects? I checked the MSDN and found naming conventions for class members, etc; but could not find information on the objects. It would be great if...
11
by: MP | last post by:
Hi, Coming from a vb6 background I am accustomed to prefixing variable names to indicate their usage. Now just beginning to try to learn database stuff I've been lurking here and working on my...
8
by: Daz | last post by:
Hi all! This question may hopefully spark a little debate, but my problem is this: I am sure it's not just me who struggles to think up names for variables. Obviously, thinking up a name...
3
by: rsine | last post by:
I have searched around a little and have yet to find a naming convention for the string builder object. I really do not want to use "str" since this is for string objects and thus could be...
35
by: Smithers | last post by:
Is it common practise to begin the name of form classes with "frm" (e.g., frmOneForm, frmAnotherForm). Or is that generally considered an outdated convention? If not "frm" what is a common or...
9
by: BillCo | last post by:
I'm coming from a MS Access background and so I'm very used to and comfortable with the hungarian (Leszynski et al) naming conventions. However, I'm getting started into my first SQL Server...
23
by: Thorsten Kampe | last post by:
Okay, I hear you saying 'not another naming conventions thread'. I've read through Google and the 'naming conventions' threads were rather *spelling conventions* threads. I'm not interested...
17
by: Miguel Guedes | last post by:
Hello, Does anyone have a link to the C++ Standard Library naming conventions that they could share? I have found a few links to pages on C++ naming conventions but am unsure as to what standard...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.