Our Blog

ASP.NET SMTP – Setting a Pickup Directory for Development

3 August 2009 17:39, Posted by Colin

One of the hidden gems of System.Net is the ability to change from using an SMTP server for sending your email. Instead you can specify a pickup directory which will receive all emails sent from your application as a .EML text file. There are clearly uses for this in production – you may have a second application which monitors this pickup directory and sends the emails after performing some processing on them.

My favourite use of this feature is for development – when you’re sending loads of test emails you can avoid polluting your inbox and simply check the pickup directory. You also avoid having to set up an SMTP host and all of the associated configuration.

Simply add the following to your web.config’s system.net section:

<mailSettings>
	<smtp deliveryMethod="SpecifiedPickupDirectory">
		<specifiedPickupDirectory pickupDirectoryLocation="c:\temp\"/>
	</smtp>
</mailSettings>

Make sure you’ve got the right permissions on the directory. Now, send an email from your application and watch it appear in c:\temp, as if by magic!



Using ASP.Net / AJAX slide extender to create a color selector

26 April 2007 18:29, Posted by Jon

Using the MS AJAX ASP.Net Extensions and the Ajax Control Toolkit (available through codeplex) You can easily make a colour selector using the Ajax Control Toolkits Slider Extender control.

The Slider Extender included in the Ajax control toolkit renders on the screen as a control that allows the user to click and drag to adjust a numerical value. Out of the box the slider extender is given an ASP:TextBox as it’s Target Control ID, the slider extender automatically hides these textboxes. We can use three slider controls to create a Red, Green and Blue sliders to set a colour. When working in RGB we can set a value of 0 to 255 for each of Red, Green or Blue. So the first thing we need is the three sliders on our HTML page.

 

ASP.Net MVC Diagram

Read more…



Tip: ASP.Net/AJAX – Javascript in Label/Textbox Text

24 April 2007 18:17, Posted by Jon

Hi All,

I though I would share a problem that I had (and resolved) using ASP.Net AJAX. The problem occurs if you want to output some Javascript to a Textbox (for example: for a user to copy and paste into their own page), which is nested in an UpdatePanel. AJAX returns an HTTP 500 error.

The reason seems to be that the Javascript in the textbox interferes with the javascript generated by MS AJAX to handle the partial page updates of the UpdatePanel.

So if like me you need to output some Javascript to the page for a user to cut and paste, a work around is to use a literal control and the HTMLEncode function of the Server object as follows:

  1. Literal1.Text = Server.HTMLEncode(<Script src=’example.js’ type=’text/javascript’></script>)

I hope that helps anyone that has been puzzled by this error.



Tim Shankarian’s MS Ajax Autocomplete Patch (and how to use)

29 March 2007 18:31, Posted by Jon

Contrary to the advise I have received from several fellow developers (and never being one to miss a challenge), I have decided to ignore all advise and attempt to use the Microsoft Ajax framework with my current .Net project for TktIt.com. The MS Ajax Frawework is extended to provide functionality such as Autocomplete etc using the AjaxToolKit. Although a lot of these are excellent, (like the pop-up calendar control) the Autocomplete feature is poor compared to many others out there. However, thanks to Tim Shankarian, it has got a little better!

Read more…



Writing an XML-RPC server or client in ASP.Net: Part 2

9 March 2007 18:33, Posted by Jon

In my previous article I covered how to setup an XML-RPC server in .Net, in particular looking at how to service XML-RPC MetaWebLog API requests. In this second part I am looking at how we can easily construct an XML-RPC client to ping blog directory or search services such as Technorati, Google BlogSearch, blo.gs etc.

Read more…



Writing an XML-RPC server or client in ASP.Net: Part 1

3 March 2007 18:33, Posted by Jon

Part Two available here

I have recently be working on a project which needed to implement the blogging MetaWebLog API, allowing users to post blog messages from their favorite blog editor, such as Windows Live Writer or blog directly from MetaWebLog API enabled websites such as Flickr or Digg. My tutorial below will show you how to easily create or consume an XML-RPC service such as the MetaWebLog API.

Read more…



Following the MVC code methodology with ASP.Net / SubSonic

1 March 2007 18:34, Posted by Jon

I have been recently getting into Ruby on Rails and wanted to share my experiences of applying a similar philosophy to ASP.Net development. One of the core principles of RoR is based on the development of dynamic websites around the Model, View, Controller Methodology. This gives a clean code separation and by following this convention we reduce the risk of duplication and always know where to look for a certain bit of functionality.

Ruby on Rails is based on the MCV model and implements it cleanly out of the box. ASP.Net is not designed around this, so we have to take a slightly different view of our ASP.Net projects to achieve the same thing.

For this approach, I am making use of the SubSonic ActionPack (Zero Code DAL). If you do not know, or have not used SubSonic before, I cannot stress enough how useful this components is. Once SubSonic is setup correctly and pointing at your database. You simply run an .aspx page that generates classes for the selected tables in your database. This allows you then to access information in the database as if a member of a class. Effectively SubSonic is a self-building Object Relational Model (ORM).

View

The View of the MVC model is as you would expect, the .apsx page itself. To follow the model other than JavaScript, etc, avoid .Net coding in this file and keep it cleanly in the code-behind page.

Controller

In the MVC model, the controller deals with the interaction between the view that the user interacts with and the model, that contains are business logic. In here our event handlers, such as button1.click etc are handled as normal, however I stress these event handlers should not contain any business logic. Instead purely use code here to control the view. For example, in here you would call the Model to get you the required information to populate to a GridView and simple databind that data. The business logic to get the required information (for example all products of a certain category) is stored in your Model.

Model

To implement the Model in the MVC model, we need to create our own classes for this. I like to group all functions that relate to a certain theme in one class or model. Using our examples of Products, I would create a ProductModel.cs file and store all my functions such as the above GetProductsByCategory() method.

By doing this I can change the business logic at any time without having to worry about which ASP.Net code behind pages I have accessed the products table from.

To show you the simplicity of SubSonic, to access the Products by a certain category we could define the following:

public static ProductCollection GetProductsByCategory(string category)
{
     SubSonic.Query query = Product.CreateQuery();
     query.AddWhere(Products.Columns.Category, category);
     ProductCollection pc = new ProductCollection();
     pc.Load(query.ExecuteReader());
     return pc;
}

That’s it no SQL, no worries, the ProductCollection, SubSonic.Query and Product classes are all generated for us by SubSonic.

SubSonic DAL/ORM

The pink classes on the diagram labeled SubSonic ActionPack are created for us and automatically built around our pre-designed database.

Helper Files

Finally the helper files are classes created by us to contain methods that we regularly use throughout our application. For example, a method to strip HTML from a string. I normally name these with Helper in the name to distinguish them from my Models and SubSonic classes.
So as you can see it is fairly easy to take the MVC approach when building a Web Application in ASP.Net. The core engine behind this is the SubSonic ActionPack which really makes all the difference.



SubSonic .Net ActionPack Starter Kit Template

28 February 2007 18:34, Posted by Jon

Having used SubSonic recently and found it an invaluable resource, reducing not only my development time, but code complexity too, I have created two Visual Studio 2005 Project Templates based on the SubSonic starter kit. I apologize if something like this already exists but I couldn\’92t find it in the official Starter Kit. I created these templates as I needed a quick way to create a new Web Site project in Visual Studio based on SubSonic with none of the example site content within.

Read more…



Go Tripod Ltd

Go Tripod Ltd is a UK-based development company working with some of the most exciting software technologies around. Simon Ashley, Jon Baker and Colin Ramsay are the brains behind projects such as Stubmatic, and are developing bespoke web, mobile and desktop software for clients with household names. We believe in good service as well as good software, and we’re eager to work with people who feel the same.