This was originally an email I sent to .NET team in my company, then decided to share as a blog post.
The problem:
- Let’s say you have a complex application, and this application (or part of it) runs very slowly. No bug s in results, no errors or exceptions, but it just so slow! Now you want to know which part of your code is the reason, which method(s) you need to go and modify., which methods take so long to execute or consume so much memory/CPU. How would you know that?
- Let’s say you want to improve the performance of your application in general (say add caching or such), so, you want to identify which parts of your code deserve your attention and will really make difference (so that you don’t waste your time on optimizing something that will not have big effect in performance), for example, you might want to identify which methods are called more than others from different parts of your code. How would you do that?
Read the full post ... (822 words, 19 images, estimated 3:17 mins reading time)
.NET, .NET FAQ, ALT.NET, Architecture, ASP.NET, ASP.NET 2.0, Link List, Miscellaneous, Visual Studio
Background (skip if you know Web Application Projects)
In VS 2002/2003, the web project model for a website was similar to “class library” projects, where you have a .CSPROJ or .VBPROJ file that keeps track of files “included” in the project, and compiles all the pages and controls code behind to a single assembly under “\bin”. Each page/control has an automatically generated .DESIGNER.CS or .DESIGNER.VB file, which contains objects mapping to the server controls in the page/control markup (the generation of those files was not always in synch with markup, and that was problematic).
With VS 2005, there was a new “website” model for web projects that compiles each page/control individually as a separate assembly (or each folder, depending on optimization features), and applies this to all files in a given directory and its sub folders. This was a total mess in most “real world” projects, as VS takes so long to build the entire website, and even at deployment, you get sometimes many problems when you have pages that “reference” other pages/controls when IIS it trying to dynamically load the right assemblies to reference, and many other problems.
Read the full post ... (1294 words, estimated 5:11 mins reading time)
.NET, .NET FAQ, ASP.NET, ASP.NET 2.0, Visual Studio, Visual Studio 2008 (Orcas)
This is problematic with ASP.NET AJAX. The main Script Components are NOT sent to the client when in :Legacy” mode. This is “By design” in ASP.NET AJAX, although it is a clear limitation!!
I’m investigating the problem for other solutions and will be sending an update soon.
Thank you, Iman Halawany, for making me note this. I’ve been working on WCF services and ASP.NET MVC stuff lately than normal webforms, so, didn’t realize this obvious showstopper.
To all my readers, I owe you a BIG apology.
The Problem
ASP.NET validators and ValidationSummary controls are rendered as SPAN tags that are shown and hidden based on validation state. The properties of the validators are written normally via JavaScript calls similar to these:
<script type=“text/javascript”>
//<![CDATA[
var Page_ValidationSummaries = new Array(document.getElementById("vdsSiteLogin"));
Read the full post ... (571 words, estimated 2:17 mins reading time)
ASP.NET, ASP.NET 2.0, ASP.NET Controls
If you have ever thought that the famous if(Page_ClientValidate("validationGroup")) {/*JS Code*/} and myValidator.ValidationGroup = "validationGroup"; are sure not enough client side capabilities in ASP.NET validators, you are right.
The list of client side API for ASP.NET Validators can be found on this MSDN page "ASP.NET Validation in Depth":
http://msdn.microsoft.com/en-us/library/aa479045.aspx#aspplusvalid_properties
Look for subtitle: "Client-Side APIs".
Thanks Simone Chiaretta for mentioning the topic, Mohamed Tayseer for sharing the topic on facebook, and Richard Cook for his comment on the post making me search for the complete list.
Permanent link to this post (96 words, estimated 23 secs reading time)
ASP.NET, ASP.NET 2.0, ASP.NET Controls
The Problem
In an N-tier application, you keep your logic in a business logic tier, typically a different VS project that can be used from a website, a windows service, or desktop application, and that should be valid to writ unit tests against on its own.
But how about if your requirements say that you need to to upload some file for the business logic to work? Think of a scanned image (signed contract maybe?) or just a comma separated value file containing some emails. Typically the business logic tier will be the place to to handle this, but how can you send the uploaded file to it? You can get the file as "HttpPostedFile" from the "Request.Files" collection or the file upload control itself, but, to receive it in the business logic, project, the easiest way is to add reference to "System.Web" dll and accept the type "HttpPostedFile" as method argument or so, and when in need to save the file physically, you call the "SaveAs" method of "HttpPostedFile" … So simple right ?
Read the full post ... (2162 words, 1 image, estimated 8:39 mins reading time)
ASP.NET, ASP.NET 2.0, ASP.NET Controls
Note: This is ported from my old weblog. Originally published June 22, 2006 |
First, I assume here that you know themes and read about them, but are a bit afraid or unfamiliar with using them. If you don’t know what are Themes and skins in ASP.NET 2.0, check their section on MSDN as well as this great article (another one).
Do you know that…
- Do you know that you can provide intellisense to skin files in VS2005? Simply go to Tools menu, click Options, and from the tree in the left, expand the node "Text Editor" to click it’s sub node "File Extension". In the "Extension" text box, write "skin", and select "User Control Editor" from the "Editor" drop down, click add, and then OK.
- Do you know that ANY stylesheet existing in the folder of the current "Theme" or "StylesheetTheme" is inked on rendering? Not just the stylesheet with the same name of the Theme, and not only when you’re using the theme as "StylesheetTheme" as some believe.
Read the full post ... (1007 words, estimated 4:02 mins reading time)
ASP.NET, ASP.NET 2.0, Web Design
This is a well commented example for a GridView with implementation of RowDataBound and DataBound events. I also demonstrate in it some of the important properties of GridView, like the slight diffrences when dealing with Grid Paging, Rows, Cells, and Columns. I prefered to heavily comment the code than to write separate paragraphs describing it as I do believe that the code is what gets the idea in a direct way.
The example is a simple page that uses SqlDataSource to connect to a SQL Server 2005 Express database and show the results on a GridView with paging capapility. Many parts of the code don’t show the best practices for their situation and those are only included for demonstration purpose as they are not the main focus of the example.
I’ll start with the code behind of the page as it’s the most important part:
Read the full post ... (983 words, 3 images, estimated 3:56 mins reading time)
.NET, .NET FAQ, ASP.NET, ASP.NET 2.0, ASP.NET Controls