Random ASP.NET Tips and Tutorials
Posted by: Suprotim Agarwal
in Category ASP.NET
Abstract: Here are some random ASP.NET tips and tutorials you will find useful
Lately I have been compiling some tutorials on Silverlight, SharePoint and LINQ and I am glad to receive good feedback on the same. Here are the links in case you missed them
Microsoft Silverlight 4 Tutorials You Must Read
50 LINQ Examples, Tips and How To's
SharePoint 2010 Tutorials For Beginners and Intermediate Developers
Continuing the link list series, here are some random ASP.NET tips and tutorials I wrote on my blog. Hope you like this list too! My goal is to add new posts to this series going forward – so bookmark this page for updates and please retweet this link to share these tips with fellow developers.
If you are an ASP.NET MVC developer, make sure you check our ASP.NET MVC tutorials over here.
Random ASP.NET Tips and Tutorials
Test Emails in ASP.NET without a Mail Server - The tip I am going to share today is an old one but many developers do not know about it. Assume you are creating an application and need to test a module that sends out bulk mails, like a newsletter. Your first thought would be to configure an SMTP server to test the email module. However there is a trick that you can make use of while testing your code.
jQuery: Highlight Source Code in HTML and ASP.NET Pages - I recently stumbled upon the Snippet plugin which is a syntax highlighting plugin and provides a quick and easy way of highlighting source code passages in HTML documents. I needed a similar implementation for displaying source code (with syntax highlighting and copy), while generating some documentation for a product. Let us see how to implement this plugin in an ASP.NET page.
Avoid DataBinder.Eval in ASP.NET and improve Performance - I see a lot of developers using DataBinder.Eval, which evaluates data-binding expressions at run time. Although the DataBinder.Eval is quite frequently used in web controls like the GridView, Repeater etc, use it with caution.
ASP.NET 4: Register HTTP Module at Runtime without Editing your Web.config - Not known to many developers, ASP.NET 4.0 provides the PreApplicationStartMethodAttribute which allows you to run code even before any app_start event gets fired or any dynamic compilation occurs (App_code). This allows use to register modules without touching your web.config
ASP.NET 4 Granular View State - In this post, we will see how to control a view state at Page level as well as Control level. In ASP.NET 4.0, Microsoft has provided a property called 'ViewStateMode' at control level. Now you can turn OFF the View state at Page level and turn ON viewstate at Control level as per your requirements.
Remove X-AspNet-Version and X-Powered-By HTTP Header using IIS - When an HTTP request is made to a web server (like IIS), HTTP headers are transferred from the Browser to the webserver and vice-versa. The HTTP Headers sent by IIS to the browser gives information like how to render the content or gives information about the web server software, version etc. One such HTTP Headers is the X-Powered-By and X-AspNet-Version which tells the browser that the site is powered by ASP.NET and the ASP.NET version that is used by the web server
Render Dynamic MetaTags in ASP.NET Page in Separate Lines - In ASP.NET using code with the HTMLMeta class, we can define the HTML meta elements on an ASP.NET page. But the output is all mixed in one line. Can i separate it ? This post shows how to do so.
Bind to Multiple ASP.NET Site Map files - You can use more than one sitemap file and decide which one to bind to a control. This post shows how to bind a control like the Menu Control, to multiple ASP.NET Site Map files.
ASP.NET: SQLDataSource QueryString Handling - I have seen a lot of developers using the QueryStringParameter with the SQLDataSource for demo ASP.NET applications. A frequently asked question is how to perform checks in cases where the parameter has the value null or Nothing and supply a default value to it.
Remove ViewState from an ASP.NET Page - In this post, we will explore how to remove ViewState from your asp.net page and instead store it in a session. This could be useful when pages are to be served to devices with less resources.
Compress Session State in ASP.NET 4 - ASP.NET 4 introduces a new option called ‘compressionEnabled’ to compress session state and improve application performance.
Auto Generate Row Number in ASP.NET ListView - Is it possible to create a counter field or an auto-generated Row Number in an ASP.NET ListView? The solution is to add <%# Container.DataItemIndex + 1 %> to the ItemTemplate of the ListView as shown in this post.
Using the Deployment retail=true attribute - ASP.NET Settings - One of the most common errors while deploying ASP.NET websites into a production environment is to leave the Trace and Debug enabled or leave the custom errors attribute disabled. If you are a web administrator and have several websites deployed on your server, then here’s a simple tip to override these deployment mistakes