Recently I discovered a better way to format my email messages in ASP.NET using the MailDefinition object. It lets you to use an email template and define tokens which you want to replace in it. This helps keep the presentation and business layers clean & seperate and lets the designers go in and edit the [...]
Posts Tagged ‘asp.net’
Code Blocks Inside Master Pages
By J in UncategorizedSome time ago I kept getting this error in one of the projects I was working on:
The Controls collection cannot be modified because the control contains code blocks (i.e. ).
I spent quite some time trying to figure it out. Finally after hours of searching I found out that Code Blocks Inside Master Pages Cause Trouble.
I [...]
Tags: asp.net, errors, masterpages
How to setup an asp.net website on localhost
By J in UncategorizedFirst lets start by setting up the site in IIS…
1.Open IIS by double-clicking on Control Panel->Administrative Tools->Internet Information Services
2.Right Click on Web Sites->Default Web Site
3.Click on Properties->Home Directory and choose the location of your website
Now lets give the ASPNET account the appropriate permissions to access that directory…
4. Using My Computer or the Windows [...]
How To Load & Reference An Usercontrol From Code Behind
By J in UncategorizedFirst lets create a sample user control called MyControl for demonstration purposes
public partial class _Controls_MyControl : System.Web.UI.UserControl
{
private string _myProperty;
public string MyProperty
{
get { return _myProperty; }
set { _myProperty [...]
Tags: asp.net, usercontrols
ASP.NET Inline Tags
By J in UncategorizedThere are all sorts of different inline tags, and I haven’t found a place that explains them all in one place, so here is the quick and dirty…
<% … %>
The most basic inline tag, basically runs normal code:
<% if (User.IsInRole(“admin”)) { %>
You can see this
<% } else { %>
You are no admin fool!
<%} %>
http://msdn2.microsoft.com/en-us/library/ms178135(vs.80).aspx
<%= … [...]
Tags: asp.net
Three quick ways optimize AJAX driven websites in ASP.NET
By J in UncategorizedRecently I was involved in a project where I had to make heavy use of AJAX. I realized there are a few simple things you could do to improve performance.
1) Combine scripts
<ajaxToolkit:ToolkitScriptManager ID=”TSM1″ runat=”Server”
EnablePartialRendering=”true”
CombineScriptsHandlerUrl=”~/CombineScriptsHandler.ashx” />
As the name of the property suggests, it will pretty much combine all the needed JS files into one which in [...]
Request.Browser.Crawler
By J in UncategorizedIn my previous post about exception logging, I show how to log several different parameters related to the exception in the database. Request.Browser.Crawler is one of them and its used to track browser crawlers. It warrants its own separate entry since it requires some extra bit of setup in the web.config to get it to [...]
Exception Logging Using The Database
By J in UncategorizedThis is a simple technique I use to log exceptions in all my web applications.
First lets start by adding the following to the web.config:
<appSettings>
<add key=”LogUnhandledExceptions” value=”true”/>
</appSettings>
Second, we add the following bit inside the Application_Error event of the Global.asax file. This will capture all the unhandled exceptions and log them into the database:
private static bool logUnhandledExceptions [...]
Tags: asp.net
The Mysterious “Invalid Parameter Used” Error
By J in UncategorizedRecently I was trying to write a little C# function for cropping images. I expected it to be a quick 5 minute task but I ended up spending a huge amount of time getting it to work correctly. I kept getting a very stubborn and mysterious error – “Invalid Parameter Used” – whenever I tried [...]
10 ASP.NET Performance and Scalability Secrets
By J in UncategorizedVery good article. Covers all the following topics:
ASP.NET Pipeline optimization
ASP.NET Process configuration optimization
Things you must do for ASP.NET before going live
Content Delivery Network
Caching AJAX calls on browser
Making best use of Browser Cache
On demand progressive UI loading for fast smooth experience
Optimize ASP.NET 2.0 Profile provider
How to query ASP.NET 2.0 Membership tables without bringing down the site
Prevent [...]
Tags: asp.net, bestpractice