gaskell.org » technical http://gaskell.org picking up where teh rest leave off Tue, 07 Jun 2011 16:38:59 +0000 en hourly 1 http://wordpress.org/?v=3.3.2 Bulletproof Ajax with ASP.NET MVC http://gaskell.org/bulletproof-ajax-with-aspnet-mvc/ http://gaskell.org/bulletproof-ajax-with-aspnet-mvc/#comments Sun, 03 Aug 2008 03:26:26 +0000 andy gaskell http://gaskell.org/?p=59 After reading the excellent Bulletproof Ajax by Jeremy Keith, I thought porting the Bulletproof Books sample application to ASP.NET MVC would be a great first attempt at building an ASP.NET MVC application. One of the main points of Bulletproof Ajax is that Ajax should be used to enhance usability and not to make Ajax a requirement to access your content. My version of the Bulletproof Books Shop also makes Javascript and XMLHttpRequest support optional.

Keeping the site accessible to most web browsers took some extra work and consideration when building the Controllers. I decided that any HomeController actions would render html for the entire page.

   13         public ActionResult Index()

   14         {

   15             ViewData.Model = Product.Products;

   16             return View(“Index”);

   17         }

   18 

   19         public ActionResult AddProductToCart(string productID, int quantity)

   20         {

   21             CartController cartController = new CartController();

   22             cartController.AddProduct(productID, quantity);

   23             return Index();

   24         }

   25 

   26         public ActionResult RateProduct(string productID, string rating)

   27         {

   28             RatingController ratingController = new RatingController();

   29             ratingController.RateProduct(productID, rating);

   30             return Index();

   31         }

Controllers that refresh partial chunks of html will know how to respond to actions (add product to cart, rate a product) and render views mapped to MVC user controls. The client will make http requests to different urls based on javascript support in the browser. For example to add a product to a cart with javascript enabled, the javascript will make a post to /Cart.mvc/AddProduct and the server will response with a chunk of html. To add a product with javascript disabled the client will post to /Home.mvc/AddProductToCart and the server will respond with an entire page. The HomeController ends up forwarding the call to the appropriate controller so we’re able to avoid duplicating logic.

   28         public ActionResult DisplayCart()

   29         {

   30             Cart cart = GetCart();

   31             return View(“Cart”, cart);

   32         }

   33 

   34         public ActionResult AddProduct(string productID, int quantity)

   35         {

   36             Cart cart = GetCart();

   37             Product product = Product.Products.Find(s => s.ID == productID);

   38             cart.AddProduct(product, quantity);

   39             SetCart(cart);

   40             return View(“Cart”, cart);

   41         }

One thing I’m not sure about is state management in ASP.NET MVC, so I’m currently storing the cart and ratings in session.

   22         private Rating GetRatings()

   23         {

   24             Rating rating = System.Web.HttpContext.Current.Session["Rating"] as Rating;

   25             if (rating == null)

   26             {

   27                 rating = new Rating();

   28             }

   29             return rating;

   30         }

   31 

   32         private void SetRating(Rating rating)

   33         {

   34             System.Web.HttpContext.Current.Session["Rating"] = rating;

   35         }

You can download the source here.
]]>
http://gaskell.org/bulletproof-ajax-with-aspnet-mvc/feed/ 6
Getting access to MSDN downloads with the Empower ISV program http://gaskell.org/getting-access-to-msdn-downloads-with-the-empower-isv-program/ http://gaskell.org/getting-access-to-msdn-downloads-with-the-empower-isv-program/#comments Sat, 12 Jul 2008 06:50:04 +0000 andy gaskell http://gaskell.org/?p=58 Ok, so like 99% of my blog entries are about things not working quite the way I think they should and here’s another example. When linking your Passport account to your MSDN Subscription you’re asked to provide your Benefit Access Number. The number they’re looking for is your Technical ID available on Microsoft Parter Program site. Under Requirements & Assets click Assign Contact Roles.

This method didn’t work for me on the day I received my MSDN shipment – I had to wait a couple days for it to work.

]]>
http://gaskell.org/getting-access-to-msdn-downloads-with-the-empower-isv-program/feed/ 0
Free (and not so free) Windows FTP Clients http://gaskell.org/free-and-not-so-free-windows-ftp-clients/ http://gaskell.org/free-and-not-so-free-windows-ftp-clients/#comments Thu, 10 Jul 2008 02:29:43 +0000 andy gaskell http://gaskell.org/?p=56 SmartFTP started charging for their Windows FTP client so I decided to look for a suitable truly free replacement (not a lite version or one with nag screens) and FileZilla seems like the best option out there.

Filezilla isn’t quite as pretty as SmartFTP but FileZilla does have a local and remote browser similiar to SmartFTP – super easy to use. I’ve used it to upload and modify files on my host as well as FTP files over to a WinCE device that I’m developing on – so far it’s worked great.

]]>
http://gaskell.org/free-and-not-so-free-windows-ftp-clients/feed/ 1
Disable Blocked File Protection Control in Windows Vista http://gaskell.org/disable-blocked-file-protection-control-in-windows-vista/ http://gaskell.org/disable-blocked-file-protection-control-in-windows-vista/#comments Fri, 27 Jun 2008 04:54:30 +0000 andy gaskell http://gaskell.org/?p=52 In my neverending quest to make Vista more usable, I finally caved and took the time to figure out how to disable Blocked File Protection Control. This “feature” requires you to unblock files you download before they are usable (for the most part). This is a bad decision in my opinion – I decided to download a file and of course I’m going to want to work with it. I don’t want to figure how how to unblock before I can use it. What a pain – anyway enough with the rant.

Unblocking files sucks

If you want to be able to use your files after you download them, you’ll need to either use the Group Policy Editor described here in as Method #3 or edit the registry.

Unfortunately I happen to be running Windows Vista Home Premium on one of my systems – this means no gpedit. The entry we need to set is:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Attachments\SaveZoneInformation

This value needs to be a DWORD set to 1. You can enter this manually or download the reg file and “Unblock” your last file! Be sure to close all instances of Internet Explorer or reboot your computer after making the change to your registry.

]]>
http://gaskell.org/disable-blocked-file-protection-control-in-windows-vista/feed/ 5
Using the digg API in an ASP.NET Page http://gaskell.org/using-the-digg-api-in-an-aspnet-page/ http://gaskell.org/using-the-digg-api-in-an-aspnet-page/#comments Sat, 21 Apr 2007 05:05:22 +0000 andy gaskell http://gaskell.org/using-the-digg-api-in-an-aspnet-page/ Digg released their API yesterday – I haven’t really done much with RESTful web services because in the .net world, most of the time SOAP/WSDL is used. I thought a very basic RESTful web service project would be useful for other .net developers.

This example gets a list of all topics that digg offers. The code is pretty simple:

// Create the web request, change the appkey to for your applications
HttpWebRequest request = WebRequest.Create("http://services.digg.com/topics?appkey=http%3A%2F%2Fgaskell.org") as HttpWebRequest;

// won't get a response from digg if UserAgent is not set
request.UserAgent = ".net"; 

// Get response
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
{
     // Get the response stream
     StreamReader reader = new StreamReader(response.GetResponseStream());

     DataSet ds = new DataSet();
     ds.ReadXml(reader);

     this.topicsGridView.DataSource = ds.Tables[1];
     this.topicsGridView.DataBind();
}    

Download the project or check out the live demo

]]>
http://gaskell.org/using-the-digg-api-in-an-aspnet-page/feed/ 1
Now with 100% more .net http://gaskell.org/now-with-100-more-net/ http://gaskell.org/now-with-100-more-net/#comments Thu, 19 Apr 2007 03:44:48 +0000 andy gaskell http://gaskell.org/now-with-100-more-net/ I host my blog on the fantastic WordPress blog platform which typically runs on the LAMP stack. That means I can’t put up live demos of my .net posts so I created a new .net playground at http://dotnet.gaskell.org. I’ll have live examples of all of my projects as well as project downloads.

To get things started here’s a live demo of the digg style paging in asp.net project I created.

]]>
http://gaskell.org/now-with-100-more-net/feed/ 0
Digg style custom paging for GridViews in ASP.NET http://gaskell.org/digg-style-custom-paging-for-gridviews-in-aspnet/ http://gaskell.org/digg-style-custom-paging-for-gridviews-in-aspnet/#comments Fri, 13 Apr 2007 01:09:45 +0000 andy gaskell http://gaskell.org/digg-style-custom-paging-for-gridviews-in-aspnet/ I’ve been on a bit of a digg kick lately and I like how they handle paging so I decided to create a GridView control that uses custom paging similar to digg’s. The algorithm is based on this post. As far as html output goes, this should be fairly close to the actual output on digg and I’m using digg’s stylesheet in the demo.

About the algorithm (from Stranger Studios):

  1. The pagination object has a “previous” and “next” button which takes the user to the next page. The previous button is disabled on the first page. Similarly, the next button is disabled on the last page.
  2. The pagination object will always display links to the first two pages and the last two pages of the set.
  3. The pagination object will always display links to the first x (adjacents in the code) pages before and after the current page.
  4. The pagination object will only show at most 5+2x links (first two + prior x + current page + next x + last two). All links not shown will be replaced by …

A little preview:
digg style paging preview

You can download the project here. I didn’t spend a ton of time testing this code, please leave any bug reports in the comments – Thanks!

Update: Changed the code a bit – paging is now handled via query string instead of posting back. Not a huge deal but the code is easier to read.

]]>
http://gaskell.org/digg-style-custom-paging-for-gridviews-in-aspnet/feed/ 8
Digg It button User Control for ASP.NET http://gaskell.org/digg-it-button-user-control-for-aspnet/ http://gaskell.org/digg-it-button-user-control-for-aspnet/#comments Sun, 08 Apr 2007 04:43:37 +0000 andy gaskell http://www.gaskell.org/digg-it-button-user-control-for-aspnet/ I came across Tuggo’s excellent diggIT plugin for WordPress and thought it’d be cool to make an ASP.NET User Control that provides similar functionality. The control is really easy to use.

Here’s the basic tag:

<uc1:DiggItButton  ID="DiggItButton"
                   runat="server"
                   Url="http://gaskell.org"
                   Title="Test title"
                   Body="Test body" />

You don’t need to set the Url, Title and Body properties in the tag, they are also available as public properties in the codebehind. The only property that is required to be set is the Url property – if you pass in the Title and/or Body, digg will pre-populate those fields. Digg also asks that you url encode your strings and this control handles that for you. Check out the code and sample page here.

]]>
http://gaskell.org/digg-it-button-user-control-for-aspnet/feed/ 1
The requested operation requires elevation in Windows Vista http://gaskell.org/the-requested-operation-requires-elevation-in-windows-vista/ http://gaskell.org/the-requested-operation-requires-elevation-in-windows-vista/#comments Thu, 14 Dec 2006 05:02:29 +0000 andy gaskell http://www.gaskell.org/the-requested-operation-requires-elevation-in-windows-vista/ So I’ve been using Vista for a few weeks now and for whatever crazy reason I decided I needed to flush dns. I received this message: “The requested operation requires elevation”. Okay, to get around this go to All Programs, Accessories, right click Command Prompt and click Run as administrator. Good to go!

run as administrator

Update:
I’ve been running Vista for quite some time now and finally got fed up with User Account Control (UAC). What UAC really turns into is security by nagging so I disabled it altogether. To disable UAC open the Control Panel/User Accounts then click Turn User Account Control on or off. Uncheck the box. Click OK.

turn off uac in the control panel

turn off user access control

]]>
http://gaskell.org/the-requested-operation-requires-elevation-in-windows-vista/feed/ 113
Hello World for Ruby on Rails http://gaskell.org/hello-world-for-ruby-on-rails/ http://gaskell.org/hello-world-for-ruby-on-rails/#comments Wed, 16 Aug 2006 05:55:03 +0000 andy gaskell http://www.gaskell.org/hello-world-for-ruby-on-rails/ I’m just getting started with Rails so I went looking for a Hello World example. Eventually I came to this post. I’m going to go over the equivalent example using the RIDE-ME IDE.

1. Create a new project. Click File – New – Project.

2. Enter C:\ in the Location textbox. Enter HelloWorld in the project name. Click OK.

New Project dialog

3. Click File – New – Controller. Enter Hello for the name of the Controller. Click OK.

New Controller dialog

4. In the Project Explorer window, expand app, expand views. Right click the hello and click on Add New RHTML Page.

Adding a new RHTML page

5. Name the file index.rhtml. Click OK.

Naming the new RHTML page

6. Type “hello world” in your rhtml page. Save the file.

7. Press F5 (or click Run) and in a few seconds the web server starts and a browser window launches. Change the URL to http://localhost:3000/hello.

8. Hello World!

I hope to post more short projects as I work my way through the PickAxe and Agile Web Development with Rails books.

]]>
http://gaskell.org/hello-world-for-ruby-on-rails/feed/ 2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 Buy Generic Methotrexate No Prescription Viagra Walmart Best Online Pharmacy For Cialis Generic Buying Femara Canadian Pharmacy No Prescription Needed Alesse Purchase No Prescription Mircette Cheapest Levitra From India Buy Tablets Actonel Online No Prescription Antibiotics Online Ordina Viagra Tricor No Prescription Acheter Diabecon Viagra Ou Equivalentes Amoxil Buy Online Cheap Cafergot Order Buy Best Generic Baclofen Tablets Without a Prescription Seroquel Order Online No Perscription Purchase Lexapro Online Without Prescription Buy Viagra Online Tabs Cheap Generic Substitute Viagra Purchase Lexapro Purchase Viagra In Australia Buy Viagra In Canada Fast Canadian Pharmacy Toronto Zithromax Order Bupropion Next Day Delivery Canadianlab Viagra Tablets Buy VentolinZovirax And Cost Levitra 20mg Tablets Generic Viagra Free Pills Viagra Professional Buy