.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old February 6th, 2004, 02:41 PM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
Click here for more information.
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,781 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 8 h 45 m 55 sec
Reputation Power: 470
Coding Tips For .NET

1) It is better to use Flow Control Layout, rather then Grid Control Layout when creating Web Applications in ASP.NET. Why, you ask??? The Grid Control uses absolute style positioning and sizing of controls, which isn't supported on all browsers.

2) When using a DataGrid that is non-editable and using column templates, don't setup any EditItemTemplate tag on any of the columns. THis add unneeded overhead to the grid. Also when using Bound Columns with your DataGrid (non-templated columns) and you are not going to be editing through the grid itself, make all of your columns ReadOnly. THis will alter the HTML that is generated to make it much "thinner" by no adding label controls for each cell of the table.

3) Append strings with & or &= instead of + or +=. The difference is when you try to append something that isn't a string. & will work + won't.

4) Use AndAlso and OrElse instead of just AND or OR. When performing an If statement in VB.NET, VB actually evaluates both expressions to see if the who expression is true. Even when the first expression is false. It continues to look at the second argument even though it doesn't have to. This very helpful when using Functions as expressions in the statemtn
Code:
Instead of doing this
If(Function1() And Function2()) Then

Do this
If(Function1() AndAlso Function2()) Then

The first code will evaluate the result of Function2(), even if Function1() returned false. The second will only evaluate Function2() if Function1() returned true.

5) Don't use Labels on a web form unless it is going to be referenced in code (changing the text or making it invisible). If the it will contain static (unchanging) text, just type it directly into the page. There's no sense in adding unnecessary overhead to your applications.

6) It is 5-6 times faster to compare the Length of a string, than it is checking for "" or NOT ""
Example:
Code:
Instead of doing this
If(txtName.Text = "") Then

Do this
If(Len(txtName.Text) = 0) Then

Or

If txtName.Text.Length = 0 Then


7) Avoid using Response.Write in ASP.NET. The ASP.NET rendering process takes place after the Response.Write would, you have no control over where the data is written to on the page (It appears at the top of the page, even above you <HTML> tag).

8) Use the Parse functions instead of CInt, CDbl, CSng, CBool, etc... The <datatype>.Parse commands are about twice as fast as their equivalent C converted commands when dealing with strings.
Example:
Code:
Dim strTemp As String = "123456"
Dim intValue As Integer
Instead of doing this
intValue = CInt(strTemp)

Do this
intValue = Integer.Parse(strTemp)


9) Avoid using empty Try...Catch blocks. Not placing code in the Catch area of the Try...Catch block is essentially the same as saying "On Error Resume Next", which can be a bad thing, especially for debugging purposes.

10) Avoid using RegisterStartupScript. This adds unnecesarry processing on the web server for handling things that should have been done in the client (like form validation). Instead use either client-side javascript or .NET's Validator controls (Compare, Custom, Required Field, Regular Expression)
Comments on this post
mumick agrees: very nice job!

Last edited by Memnoch : April 18th, 2005 at 06:27 PM.

Reply With Quote
  #2  
Old March 5th, 2004, 03:07 PM
greg greg is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 3 greg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
6) It is 5-6 times faster to compare the Length of a string, than it is checking for "" or NOT ""
Instead of doing this
If(txtName.Text = "") Then

Do this
If(Len(txtName.Text) = 0) Then

its also significantly faster to avoid the vb compatability namespace

Reply With Quote
  #3  
Old March 9th, 2004, 01:54 PM
danhe1983 danhe1983 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 8 danhe1983 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Flow and Grid control layout

What is the difference between flow and grid control layout?
How can I set my web appliction to use one of the two layouts?

thanks

Reply With Quote
  #4  
Old March 9th, 2004, 02:14 PM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
Click here for more information.
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,781 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 8 h 45 m 55 sec
Reputation Power: 470
The difference is Grid Control layout uses absolute style positioning and sizing of controls, which isn't supported on all browsers.
The default is Grid Control Layout.
The documents pageLayout property.

Reply With Quote
  #5  
Old April 21st, 2004, 04:29 AM
mamtak20000 mamtak20000 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 1 mamtak20000 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Code in aspx or aspx.vb

I have a query ...I am a beginner
want to know that for ASP.NET programming the code should be written in
test.aspx page or in test.aspx.vb page

and why?

Reply With Quote
  #6  
Old April 21st, 2004, 10:42 AM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
Click here for more information.
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,781 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 8 h 45 m 55 sec
Reputation Power: 470
post your question in it's own separate thread.

Reply With Quote
  #7  
Old May 8th, 2004, 02:07 AM
vb.net vb.net is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 11 vb.net User rank is Private First Class (20 - 50 Reputation Level)vb.net User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 39 m 29 sec
Reputation Power: 0
11: if using structured error handling, close your database connection in the FINALLY block. this ensures the connection gets closed in all cases.

c# ex:

Code:
try
{ 
//connect to DB, do stuff
oConn.Close(); //optional - will not cause error if closed again in FINALLY block.
}
catch (SqlException ex)
{
//error handling
}
finally
{
//close connection
oConn.Close();
}
Comments on this post
D.O.M.I.N.A.T.O.R agrees: Good point!

Reply With Quote
  #8  
Old June 7th, 2004, 04:03 AM
padmini padmini is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 3 padmini User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally Posted by mamtak20000
I have a query ...I am a beginner
want to know that for ASP.NET programming the code should be written in
test.aspx page or in test.aspx.vb page

and why?
hi! the file test.aspx.vb is known as code behind file. this file is used to separate
ur design and logic. that is all ur design (screen design's corresponding code) will collected in test.aspx and
the execution part will collected in test.aspx.vb
so better write code in test.aspx.vb

Reply With Quote
  #9  
Old December 13th, 2004, 04:01 PM
mwalts's Avatar
mwalts mwalts is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Location: Victoria, BC Canada
Posts: 482 mwalts User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 10 m 30 sec
Reputation Power: 5
12) Try and avoid throwing exceptions whenever possible if programming for a computer using a deep pipeline CPU (i.e. a P4). When an exception occurs, the CPU must save context and clear the entire pipe-line. There is also some overhead in the Common Language Runtime to deal with them I have noticed a visible stutter on a 2.4 ghz machine when a simple number parsing exception occurs in a .NET application

13) In ASP.NET, either avoid more advanced server controls (including panels) or update your servers browser tabs to allow non-IE browsers to correctly view your site. By default the XML file which tells the server which browsers can handle which commands (i.e. CSS, tables, frames etc) says that mozilla and company cannot handle CSS (hopefully will be fixed in 2.0) which is why the browser tabs must be updated

Reply With Quote
  #10  
Old January 14th, 2005, 09:01 AM
debdatta debdatta is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 1 debdatta User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Give some tips of interoperability between Java and .Net. Actually we have to make the presentation layer in .Net. So , we have to convert the code of JSP in ASP.Net. So give me suggestion about how to do that. And without third-party tools. If possible plz give some examples code for that.....

Regard,
Debdatta

Reply With Quote
  #11  
Old March 15th, 2005, 06:20 PM
gregory.owen@hp's Avatar
gregory.owen@hp gregory.owen@hp is offline
Maniac
ASP Free Novice (500 - 999 posts)
 
Join Date: Sep 2003
Location: Sweet Home, Oregon
Posts: 548 gregory.owen@hp User rank is Sergeant (500 - 2000 Reputation Level)gregory.owen@hp User rank is Sergeant (500 - 2000 Reputation Level)gregory.owen@hp User rank is Sergeant (500 - 2000 Reputation Level)gregory.owen@hp User rank is Sergeant (500 - 2000 Reputation Level)gregory.owen@hp User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 3 Days 4 h 37 m 8 sec
Reputation Power: 14
TIP: StringBuilder vs String Concatenation

TIP: Never concatenate strings in a loop -- use a StringBuilder instead. There is a HUGE difference in resource usage in this one.
Comments on this post
D.O.M.I.N.A.T.O.R agrees!

Reply With Quote
  #12  
Old May 15th, 2005, 12:35 AM
gregory.owen@hp's Avatar
gregory.owen@hp gregory.owen@hp is offline
Maniac
ASP Free Novice (500 - 999 posts)
 
Join Date: Sep 2003
Location: Sweet Home, Oregon
Posts: 548 gregory.owen@hp User rank is Sergeant (500 - 2000 Reputation Level)gregory.owen@hp User rank is Sergeant (500 - 2000 Reputation Level)gregory.owen@hp User rank is Sergeant (500 - 2000 Reputation Level)gregory.owen@hp User rank is Sergeant (500 - 2000 Reputation Level)gregory.owen@hp User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 3 Days 4 h 37 m 8 sec
Reputation Power: 14
If you are using Sql Server for your backend
Use Enterprise Library
__________________
c# coders are more sensitive (case sensitive, that is)

277.1826 Hz

Reply With Quote
  #13  
Old May 18th, 2005, 05:09 PM
MBirchmeier MBirchmeier is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2005
Posts: 50 MBirchmeier User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 45 m 10 sec
Reputation Power: 4
14.) (or whatever number you're on) in C# use regions, (and VB or something else too if you can)

By putting 'region' and 'endregion' directives around your code you can collapse it in the .NET environment. This way if you have an overly complex piece of code you can summarize it and collapse it to one line, and only open it up if you need to.

Code:
   // some code

[-]#region Really Long Complex Math That Fixes the DataGrid
    // lots of long lines
    // obscure logic
    // annoying syntax
    #endregion

   // some more code
    


upon hitting the [-] it will collapse to
Code:
    //some code

[+][Really Long Complex Math Taht Fixes the DataGrid]

    //some more code


use these and you can better tell at a glance what your code does, and when debugging only open the pieces that you care about when something breaks.

-MBirchmeier

Reply With Quote
  #14  
Old May 19th, 2005, 05:51 PM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
Click here for more information.
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,781 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 8 h 45 m 55 sec
Reputation Power: 470
In VB you can do regions like this
Code:
#Region "Variable Declaration..."

   Public mstrValue As String

#End Region
Comments on this post
MBirchmeier agrees: thanks... not familiar with VB to know the syntax nuances

Reply With Quote
  #15  
Old May 27th, 2005, 11:02 AM
jobo jobo is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 141