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 }
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 }
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 }
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.
]]>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.
]]>
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.
]]>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();
}
]]>To get things started here’s a live demo of the digg style paging in asp.net project I created.
]]>About the algorithm (from Stranger Studios):
- 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.
- The pagination object will always display links to the first two pages and the last two pages of the set.
- The pagination object will always display links to the first x (adjacents in the code) pages before and after the current page.
- 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:
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.
]]>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.
]]>
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.


1. Create a new project. Click File – New – Project.
2. Enter C:\ in the Location textbox. Enter HelloWorld in the project name. Click OK.

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

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

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

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