Posts Tagged ‘asp.net’

March 18, 2010 2

How to parse Wordpress RSS feed using LINQ

By J in Uncategorized

Here’s a code snippet of parsing a typical Wordpress RSS feed using LINQ. Note, we have to skip the first image from the media element since that’s usually a gravatar of the author.
Everything else is pretty straight forward.

private void BindBlogFeed()
{
[...]

Tags: , ,

October 25, 2008 1

Send Templated Emails Using MailDefinition Object

By J in Uncategorized

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 [...]

Tags: ,

September 26, 2008 0

Code Blocks Inside Master Pages

By J in Uncategorized

Some 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: , ,

September 12, 2008 0

How to setup an asp.net website on localhost

By J in Uncategorized

First 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 [...]

Tags: ,

September 1, 2008 0

How To Load & Reference An Usercontrol From Code Behind

By J in Uncategorized

First 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: ,

June 25, 2008 5

ASP.NET Inline Tags

By J in Uncategorized

There 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:

April 18, 2008 4

Three quick ways optimize AJAX driven websites in ASP.NET

By J in Uncategorized

Recently 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 [...]

Tags: ,

April 8, 2008 0

Request.Browser.Crawler

By J in Uncategorized

In 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 [...]

Tags: ,

April 8, 2008 1

Exception Logging Using The Database

By J in Uncategorized

This 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:

March 29, 2008 0

The Mysterious “Invalid Parameter Used” Error

By J in Uncategorized

Recently 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 [...]

Tags: ,