Powered by Blogger.
Showing posts with label Tips and Tricks. Show all posts
Showing posts with label Tips and Tricks. Show all posts

Thursday, August 26, 2010

Dump That Free Hit Counter And Start Tracking

Dump That Free Hit Counter And Start Tracking

It seems that every other web site we visit has some sort of hit counter on the main page, supposedly telling us how many people have been there before us. This week we're going to address this popular trend, explain why you don't need one, and what you should be doing instead.
Most Internet marketers will normally implement a hit counter on their site for one or both of two reasons -- to give them a rough estimate of the number of visitors, and/or to give visitors the impression that their site is popular and thus worthy of a good look.
Let's consider the first reason. There is nothing wrong with wanting to know how many people have visited your web site, in fact it's something that you really do need to know. But putting a visible hit counter on your home page is not the answer, especially not one of those free services.
For one thing, the free services require you to in some way promote their site. For another, they are normally slow and increase the time it takes for your pages to load. But most importantly, a hit counter doesn't provide you with all of the information you need.

Tuesday, August 24, 2010

4-Tier Architecture in ASP.NET with C#

Well, the architecture I am going to demonstrate here is just enhancement of 3-Tier archicture. In this architecture; you no need of writing long function parameters throughout the layers (as in traditionally 3-Tier archicture has to) and the actual objects of the application will be in a separate tier so that in future you can separately use these objects for enhancements. Change in the object definition can be done without touching the entire Business Access Layers ............
Let me explain you step-wise process of creatioin of 4-Tier architecture application.
In this application, I am going to take example of a Person that will have 3 properties: FirstName, LastName, Age. We will create a separate pages to insert these records (default.aspx) into database and list,update,delete records (list.aspx) from database.

Wednesday, August 18, 2010

The Total Newbie’s Guide to jQuery: Select Elements and Manipulate CSS with jQuery

This article, as well as a follow-up article coming next week, are excerpts from Chapter 2 of the new SitePoint book, jQuery: Novice to Ninja, by Earle Castledine and Craig Sharkie. You can grab the entirety of Chapter 2, as well as Chapters 1 and 7 and the complete code archive for the entire book for free here. Together, these two articles constitute an introduction to jQuery for designers who’ve only ever worked with CSS and HTML.
If you’ve been wanting to learn the basics of jQuery and start adding some dynamic interactions to your website, this is the place to start. If you’d like to follow along with the code in this article, download the sample, which includes all of the code examples from the book.

Speed Up Your Site! 8 ASP.NET Performance Tips (part 6)

Lack of Indexes
The ability to index data is one of the key benefits of storing information in a database. Imagine for a moment that you need to look up a name in a telephone book. You take advantage of the fact that the last names are sorted in alphabetic order -- it would take forever to find a name if the entries were listed in random order. Databases take advantage of the way your information is sorted for the same reason. The default sort order in a table is called a clustered index.

Speed Up Your Site! 8 ASP.NET Performance Tips (part 4)

How can I improve the speed of my site?
Most ASP.NET web servers perform a lot of unnecessarily repetitive work.
For example, suppose you have a page with a DataGrid bound to a table called Products. Every time a user requests the Products page, ASP.NET has to:
  1. Look up the products data in the database.

  2. Process the page.

  3. Databind the product data.

  4. Render the results to HTML.

  5. Output the results to the browser.

Tuesday, August 17, 2010

Speed Up Your Site! 8 ASP.NET Performance Tips (part 3)

How can I decrease the bandwidth that my site uses?
ASP.NET abstracts a lot of traditional web development details from the developer. Just drag and drop a few controls on a form, set some properties, write a little bit of code, and -- bam! -- you've got a functioning web site.
However, that doesn't mean the resulting HTML markup will necessarily be efficient or small. It's not unusual to see ASP.NET pages that contain more than 100 kilobytes of markup. I recommend that you keep a close eye on the HTML markup that results from your ASP.NET web pages -- to keep these file sizes in check can sometimes require additional effort, which is one reason we covered the topic of web standards in Chapter 9, ASP.NET and Web Standards.

Speed Up Your Site! 8 ASP.NET Performance Tips (part 2)

How can I decrease the size of the view state?
One convenience of ASP.NET controls is that they can preserve state across postbacks -- a topic we've covered in depth in Chapter 6, Maintaining State. This, of course, is a feature that comes at a price -- to implement it, we add a hidden field to the page to store the control settings for transmission between the client and server, but depending on the controls the page uses, the view state can sometimes become quite large.
One obvious way to reduce the size of view state is to turn it off if you don't need it. This adjustment can be performed either at the page level, or at the control level. If, for whatever reason, you can't disable the view state (for example, your page uses controls that are dependent upon the view state), there are a few other steps you can take to at least reduce its impact on your page size.

Adding Markers to a Map Using the Google Maps API and jQuery

The Google Maps API provides a sophisticated way for developers and webmasters to add custom interactive maps to their websites. Version 3 of the API, released in May of 2009, represents a complete overhaul of the API in response to several years worth of user feedback on the previous version.
In this tutorial we’ll cover a few of the API’s simpler features by showing you how to add a map with a set of location markers to a website. Each marker will have an associated info bubble with the name and address of the location. What’s more, we’ll be loading the location data via Ajax, so this can be used as the first step towards developing a more sophisticated map-based application.

Tuesday, August 3, 2010

Remove empty lines in Visual Studio

Visual Studio has ability to delete empty lines in replace operation using regular expressions.
1. Click Ctrl-H (quick replace)
2. Check "Use Regular Expressions"
3. In Find type ^$\n 
4. In Replace box set empty.
5. Click "Replace All"
All empty lines will be deleted.

 Regular expression for empty line consist of   
Beginning of line ^
End of line $
Line break \n

Monday, August 2, 2010

Speed Optimization in ASP.NET 2.0 Web Applications


Overview

Developing a web application that responds to users requests quickly is a target and a challenge for all web developers. ASP.NET was designed with speed optimization and performance improvements in mind. The set of enhancements like: Pages compilation, and Automatic storage on the server are new to ASP.NET.
However, these enhancements are not enough to protect you from slow performance when a large number of  http requests are simultaneously processed by your web application.
To write a well performing web application you must make a balance between four common performance measures. These measures are:
Execution Time: It is the time taken to process a request. This is measured as the time elapsed between the first byte received from the server and the last one.
Response Time: It is the time between issuing a request and the first byte received as a response from the server.
Scalability: It measures the performance of a web application against resources (memory, processors, or computers) allocated for it.
Throughput: It is the number of requests your application can serve in a time unit, usually a second.
What follows is a list of areas that you can invoke to harvest for techniques that you can use to develop a high performance ASP.NET application.

Friday, July 30, 2010

Deleting Rows Duplicate when the table doesn’t have a primary key

Were you ever in need of something like, deleting duplicate rows when the table doesn’t have a primary key. If yes, read on!

This article gives a quick way of deleting duplicate records from a given table, that doesn’t have a primary key. Also, we will NOT use cursors, loops, temporary tables (global or local) but still accomplish the mission. Interesting! isn't it. Please read on!

First lets create a simple table with two columns and name the table as ‘DeleteDupsTable’.

Tuesday, July 20, 2010

Using IIS7 on Vista with VS 2005

A few people have pinged me over the last week asking about how to use VS 2005 with an IIS 7.0 web-site on Windows Vista.  Specifically, they've run into an issue where they see a dialog message asking them to install the FrontPage Server Extensions, or they get a "You must be a member of the administrators group" message when they try to connect (see dialog below):


Monday, July 19, 2010

Website Grader: Free Website Analytics and Traffic Measurement Tool

How attractive and effective is your blog or website? How competitive and how popular is your website compared to other websites which have similar content? Looking for a way to improve the volume and quality of traffic to your website or blog via algorithmic search result? A new website measuring tool, Website Grader, can do the measurement work and assist you to improve your website.

Saturday, July 17, 2010

How to get the value of Textbox, CheckBoxlist, RadioButtonList, ListBox, DropDownList in javascript

Introduction

This Article explains you how to Raise Client Click Events for Server Controls
usage:
1.Attribute 'OnClientClick':-The OnClientClick property is used to sets a client side script or Method to be run when the Button control is clicked.
eg:OnClientClick ="return javascriptMethod()"

Country List in ASP.NET

Introduction

Developing one Customer registration page we need country name most of the time. But its very difficult to remember all the country name and bind it to country dropdown list. This article will help us to get all the country name.

Thursday, July 15, 2010

Checking / UnChecking all checkboxes of the page dynamically in a single click

Introduction
Generally we came acroos in this situation when we need to facilitate the user to select or delsect all records of the page at a single click instead of selecting records one by one.  You can refer to below picture for example.

Best Practices to Improve ASP.Net Web Application Performance

Introduction
 
Performance tuning can be tricky. It's especially tough in Internet-related projects with lots of components running around, like HTML client, HTTP network, Web server, middle-tier components, database components, resource-management components, TCP/IP networks, and database servers. Performance tuning depends on a lot of parameters and sometimes, by changing a single parameter, performance can increase drastically.

Tip/Trick: Optimizing ASP.NET 2.0 Web Project Build Performance with VS 2005

This posts covers how to best optimize the build performance with Visual Studio 2005 when using web projects.  If you are experiencing slow builds or want to learn how to speed them up please read on.
Quick Background on VS 2005 Web Site Project and VS 2005 Web Application Project options
VS 2005 supports two project-model options: VS 2005 Web Site Projects and VS 2005 Web Application Projects. 
VS 2005 Web Site Projects were built-in with the initial VS 2005 release, and provide a project-less based model for doing web development that uses that same dynamic compilation system that ASP.NET 2.0 uses at runtime.  VS 2005 Web Application Projects were released as a fully supported download earlier this spring, and provide a project model that uses a MSBuild based build system that compiles all code in a project into a single assembly (similar to VS 2003 -- but without many of the limitations that VS 2003 web projects had with regard to FrontPage Server Extensions, IIS dependencies, and other issues).  To learn more about VS 2005 Web Application Projects, please review the tutorials I've published on my http://webproject.scottgu.com web-site.  Note that VS 2005 Web Application Project support will be included in VS 2005 SP1 (so no additional download will be required going forward).
Both the VS 2005 Web Site Project option and the VS 2005 Web Application Project option will continue to be fully supported going forward with future Visual Studio releases.  What we've found is that some people love one option, while disliking the other, and vice-versa.  From a feature perspective there is no "one best option" to use - it really depends on your personal preferences and team dynamics as to which will work best for you.  For example: a lot of enterprise developers love the VS 2005 Web Application option because it provides a lot more build control and team integration support, while a lot of web developers love the VS 2005 Web Site model because of its "just hit save" dynamic model and flexibility.
Two articles you might find useful to decide which works best for you is this MSDN whitepaper that includes some comparisons between the two models, and Rick Strahl's Web Application Projects and Web Deployment Projects are Here article that provides a good discussion of the pros/cons of the different options.
To migrate from the VS 2005 Web Site Project model to the VS 2005 Web Application Project model, please follow this C# or VB tutorial that walks-through the steps for how to-do so.
So Which Project Option Builds Faster?
When doing full builds of projects, the VS 2005 Web Application Project option will compile projects much faster that the VS 2005 Web Site Project option.  By "full build" I mean cases where every class and page in a project is being compiled and re-built - either because you selected a "Rebuild" option within your "build" menu, or because you modified code within a dependent class library project or in the /app_code directory and then hit "build" or "ctrl-shift-b" to compile the solution. 
There are a few reasons why the VS 2005 Web Application Project ends up being significantly faster than Web Site Projects in these "full rebuild" scenarios.  The main reason is that (like VS 2003), the VS 2005 Web Application Project option only compiles your page's code-behind code and other classes within your project.  It does not analyze or compile the content/controls/in-line code within your .aspx pages -- which means it does not need to parse those files.  On the downside this means that during compilation it will not check for errors in those files (unlike the VS 2005 Web Site Project option which will identify any errors there).  On the positive side it makes compilations much faster.
So does this mean that you should always use the VS 2005 Web Application Project option to get the fastest build times with large projects?  No -- not necessarily.  One nice feature that you can enable with the VS 2005 Web Site Project option is support for doing "on demand compilation".  This avoids you having to always re-build an entire project when dependent changes are made -- instead you can just re-build those pages you are working on and do it on-demand.  This will lead to significant build performance improvements for your solution, and can give you a very nice workflow when working on very large projects.  I would definitely recommend using this option if you want to improve your build performance, while retaining the flexibility of the web-site model.
The below sections provide specific tutorials for both the VS 2005 Web Site Project Model and the VS 2005 Web Application Project Model on optimization techniques -- including the "on demand compilation" build option I described above.
Specific Tips/Tricks for Optimizing VS 2005 Web Site Project Build Times
When using the VS 2005 Web Site Project model, you can significantly improve build performance times by following these steps:
1) Verify that you are not suffering from an issue I call "Dueling Assembly References".  I describe how to both detect and fix this condition in this blog post.  If you are ever doing a build and see the compilation appear to pause in the "Validating Web Site" phase of compilation (meaning no output occurs in the output window for more than a few seconds), then it is likely that you are running into this problem.  Use the techniques outlined in this blog post to fix it.
2) Keep the number of files in your /app_code directory small.  If you end up having a lot of class files within this directory, I'd recommend you instead add a separate class library project to your VS solution and move these classes within that instead since class library projects compile faster than compiling classes in the /app_code directory.  This isn't usually an issue if you just have a small number of files in /app_code, but if you have lots of directories or dozens of files you will be able to get speed improvements by moving these files into a separate class library project and then reference that project from your web-site instead.  One other thing to be aware of is that whenever you switch from source to design-view within the VS HTML designer, the designer causes the /app_code directory to be compiled before the designer surface loads.  The reason for this is so that you can host controls defined within /app_code in the designer.  If you don't have an /app_code directory, or only have a few files defined within it, the page designer will be able to load much quicker (since it doesn't need to perform a big compilation first).
3) Enable the on-demand compilation option for your web-site projects.  To enable this, right-click on your web-site project and pull up the project properties page.  Click the "Build" tab on the left to pull up its build settings.  Within the "Build" tab settings page change the F5 Start Action from "Build Web Site" to either the "Build Page" or "No Build" option.  Then make sure to uncheck the "Build Web site as part of solution" checkbox:

When you click ok to accept these changes you will be running in an on-demand compilation mode.  What this means (when you select the "Build Page" option in the dialog above) is that when you edit a page and then hit F5 (run with debugging) or Ctrl-F5 (run without debugging) the solution will compile all of the class library projects like before, then compile the /app_code directory and Global.asax file, and then instead of re-verifying all pages within the web-site it will only verify the current page you are working on, and any user controls that the page references.  With large (and even medium) projects with lots of pages, this can obviously lead to major performance wins.  Note that ASP.NET will automatically re-compile any other page or control you access at runtime -- so you will always have an up-to-date and current running application (you don't need to worry about old code running).  You can optionally also use the "No Build" option to by-pass page-level validation in the IDE, which obviously speeds up the entire process much further (I'd recommend giving both options a try to see which you prefer). 
By deselecting the "Build Web site as part of solution" checkbox, you will find that the Ctrl-Shift-B keystroke (which builds the solution) will continue compiling all class library projects, but will not re-build all pages within your web-site project.  You will still get full intellisense support in your pages in this scenario - so you won't lose any design-time support.  You will also continue to get warning/error squiggles in code/class when they are open.  If you want a way to force a re-build to occur on pages not open, or across all pages within the web-site, you can use the "Build Page" or "Build Web Site" menu options within the "Build" menu of Visual Studio:

This gives you control as to which pages on your site you want to verify (and when) - and can significantly improve build performance.  One trick I recommend doing is adding a new shortcut keystroke to your environment to allow you to quickly short-cut the "Build Page" menu option to avoid you having to ever use a mouse/menu for this.  You can do this by selecting the Tools->Customize menu item, and then click the "Keyboards" button on the bottom-left of the customize dialog.  This will bring up a dialog box that allows you to select the VS Build.BuildPage command and associate it within any keystroke you want:

Once you do this, you can type "Ctrl-Shift-P" (or any other keystroke you set) on any page to cause VS to compile any modified class library project (effectively the same thing that Ctrl-Shift-B does), then verify all classes within the /app_code directory, and then re-build just the page or user control (and any referenced master pages or user controls it uses) that you are working on within the project.
Once the above steps are applied, you should find that your build performance and flexibility is much improved - and that you have complete control over builds happen.
Specific Tips/Tricks for Optimizing VS 2005 Web Application Project Build Times
If you are using the VS 2005 Web Application project option, here are a few optimizations you might want to consider:
1) If you have a very large project, or are working on an application with many other developers, you might want to consider splitting it up into multiple "sub-web" projects.  I wouldn't necessarily recommend this for performance reasons (unless you have thousands and thousands of pages it probably doesn't make a huge difference), but it can sometimes make it easier to help manage a large project.  Please read this past blog-post of mine on creating sub-web projects to learn how to use this.
2) Consider adding a VS 2005 Web Deployment project to your solution for deep verification.  I mentioned above that one downside of using the VS 2005 Web Application Project option was that it only compiled the code-behind source code of your pages, and didn't do a deeper verification of the actual .aspx markup (so it will miss cases where you have a mis-typed tag in your .aspx markup).  This provides the same level of verification support that VS 2003 provided (so you aren't loosing anything from that), but not as deep as the Web Site Project option.  One way you can still get this level of verification with VS 2005 Web Application Projects is to optionally add a VS 2005 Web Deployment Project into your solution (web deployment projects work with both web-site and web-application solutions).  You can configure this to run only when building "release" or "staging" builds of your solution (to avoid taking a build hit at development time), and use it to provide a deep verification of both your content and source code prior to shipping your app. 
Common Tips/Tricks for Optimizing any VS 2005 Build Time
Here are a few things I recommend checking anytime you have poor performance when building projects/solutions (note: this list will continue to grow as I hear new ones - so check back in the future):
1) Watch out for Virus Checkers, Spy-Bots, and Search/Indexing Tools
VS hits the file-system a lot, and obviously needs to reparse any file within a project that has changed the next time it compiles.  One issue I've seen reported several times are cases where virus scanners, spy-bot detecters, and/or desktop search indexing tools end up monitoring a directory containing a project a little too closely, and continually change the timestamps of these files (they don't alter the contents of the file - but they do change a last touched timestamp that VS also uses).  This then causes a pattern of: you make a change, rebuild, and then in the background the virus/search tool goes in and re-searches/re-checks the file and marks it as altered - which then causes VS to have to re-build it again.  Check for this if you are seeing build performance issues, and consider disabling the directories you are working on from being scanned by other programs.  I've also seen reports of certain Spybot utilities causing extreme slowness with VS debugging - so you might want to verify that you aren't having issues with those either.
2) Turn off AutoToolboxPopulate in the Windows Forms Designer Options
There is an option in VS 2005 that will cause VS to automatically populate the toolbox with any controls you compile as part of your solution.  This is a useful feature when developing controls since it updates them when you build, but I've seen a few reports from people who find that it can cause VS to end up taking a long time (almost like a hang) in some circumstances.  Note that this applies both to Windows Forms and Web Projects.  To disable this option, select the Tools->Options menu item, and then unselect the Windows Forms Designer/General/AutoToolboxPopulate checkbox option (for a thread on this see: http://forums.asp.net/1108115/ShowPost.aspx).
3) Examine which 3rd party packages are running in Visual Studio
There are a lot of great 3rd party VS packages that you can plug into Visual Studio.  These deliver big productivity wins, and offer tons of features.  Occasionally I've seen issues where performance or stability is being affected by them though.  This is often true in cases where an older version (or beta) of one of these packages is being used (always keep an eye out for when a manufacturer updates them with bug-fixes).  If you are seeing issues with performance or stability, you might want to look at trying a VS configuration where you uninstall any additional packages to see if this makes a difference.  If so, you can work with the 3rd party manufacturer to identify the issue. 
Visual Basic Build Performance HotFix
The Visual Basic team has released several hotfixes for compilation performance issues with large VB projects.  You can learn how to obtain these hotfixes immediately from this blog post.  The VB team also has a direct email address -- vbperf@microsoft.com -- that you can use to contact them directly if you are running into performance issues.

Hope this helps,
Scott

  ©Template by Dicas Blogger.

TOPO