Anant Anand Gupta Let Me Make You Think Like Me

6May/100

How To: Provide Save File Dialog for an Image Request in ASP.Net

It is the default behavior of the web browsers, when you click on the image link, to open the image and display it over there. There are instances when you might want your users to remain on the page and simply download and save the image after clicking on the image link.

This functionality can be achieved in ASP.Net. Here I am going to show how to:

Create a blank ASP.Net Web Application. Now you have to create a folder to store the image to be downloaded and add and image to it.

Your solution should look similar to this:

Open the Default.aspx and create a HyperLink to the image like this:

<asp:HyperLink ID="hlDownloadImage" runat="server" NavigateUrl="~/Images/image001.jpg?Action=Download">Download Image</asp:HyperLink>

Note that the image URL is having additional parameter "Action" with value "Download". We will see the utilization of the same in a moment.

now go and add a new file of Type ASP.Net Module ImageDownload.cs to the solution and modify the code as below:

public class ImageDownload : IHttpModule
{
    #region IHttpModule Members
    public void Dispose() { }

    public void Init(HttpApplication context)
    {
        context.BeginRequest += new EventHandler(context_BeginRequest);
    }
    #endregion

    public void context_BeginRequest(object sender, EventArgs e)
    {
        HttpApplication app = (HttpApplication)sender;
        HttpRequest req = app.Request;
        HttpResponse res = app.Response;
        if (req.Params["Action"] != null && req.Params["Action"].ToString() == "Download")
        {
            string path = req.AppRelativeCurrentExecutionFilePath;
            res.ContentType = "image/jpeg";
            res.AppendHeader("Content-Disposition", "attachment; filename=" + Path.GetFileName(path));
            res.TransmitFile(app.Server.MapPath(path));
            res.End();
        }
    }
}

Modify the web.config file to include following in <httpModules> section:

<add name="ImageDownload" type="WebUploadManager.ImageDownload"/>

You are done. Run the application and click on the Link for the image and you will see the Run/Save dialog. Try removing the Action parameter from the NavigationURL of the hyperlink; image will be displayed on screen as the default behavior of the browser.

Google Ads will be placed here.
Filed under: ASP.Net, C# No Comments
17Jan/101

Windows 7 (Seven) Shortcuts

Here are few very nice and useful shortcuts available in Microsoft's latest operating system Windows 7 (Seven):

Win + Home Minimize all the windows except the current window.
Win + SpaceBar Key Visible windows becomes transparent so you can see the desktop.
Win + Up Arrow Maximize the current window.
Win + Shift + Up Arrow Vertically Maximize the current window.
Win + Down Arrow Restore / Minimize the current window.
Win + Left Arrow Fit window in the left half of the screen.
Win + Right Arrow Fit window in the right half of the screen.
Win + Number (1-9) Open the in the order arranged in the taskbar.
Win + Ctrl + Number (1-9) Toggle the opened windows in same order as they are on taskbar
Win + Alt + Number (1-9) Open Jump List of the apps in the same order as they are on taskbar.
Win + T Focus the taskbar buttons to navigate in.
Win + B Focus the System Tray butoms to navigate in.
Ctrl + Shift + N Create New Folder in explorer or desktop.
Alt + Up Arrow Move up a directory level.
Alt + P Open/Close preview pan in explorer.
Win + P Select the display mode if multiple displays are attached.
Win + Num Pad (+/-) Magnifier Zoom In/Out.
Win + G Navigate in Desktop Gedgets
Win + L Lock Computer (old shortcut)
Win + Tab Windows 3D.
16Jan/100

Design Patterns

What is a Design Pattern?

If you are here reading this post you might be looking a knowledge on Design Patterns and the first question which comes on anyone's mind is "What is a Design Pattern?". Lets answer this question in your own way.

You are person who know the syntax of a programming language and you are able to successfully convert any requirement into the code. One fine morning you reach office and your senior tells you about a new project requirement. You understood the requirement and have decided whats need to be done and what are the object of classes required to achieve this. But internally, whole the time from beginning to the end of the development you always know that there can be a better way to achieve this, and of course you search for other solutions to. Whatever you decide to implement you will finish off the task, but was that the best solution for the requirement? When this question comes in to you mind, the answer can be only given in terms of Design Patterns.

A design Pattern is nothing but a conceptual way to represent a reusable solution for a typical problem.

Here is a list of all known Design Patterns:

  1. Strategy Design Pattern
  2. Decorator Design Pattern
  3. Factory Design Pattern
  4. Observer Design Pattern
  5. Chain of Responsibility Design Pattern
  6. Singleton Design Pattern
  7. Flyweight Design Pattern
  8. Adapter Design Pattern
  9. Facade Design Pattern
  10. Template Design Pattern
  11. Builder Design Pattern
  12. Iterator Design Pattern
  13. Composite Design Pattern
  14. State Design Pattern
  15. Proxy Design Pattern
  16. Command Design Pattern
  17. Mediator Design Pattern
  18. Abstract Factory Design Pattern
  19. Prototype Design Pattern
  20. Bridge Design Pattern
  21. Interpreter Design Pattern
  22. Memento Design Pattern
  23. Visitor Design Pattern
  24. Circular Design Pattern
  25. Double Buffer Design Pattern
  26. Recycle Bin Design Pattern
  27. Model-View-Controller Design Pattern
  28. Model-View-View-Model Design Pattern

I will updating the details of each kind of design patterns as soon as they are ready to be posted.

Filed under: Programming No Comments
3Sep/090

Jean Dubost Laguiole 6-Piece Steak Knives (Stainless Steel

Laguiole Stainles Steel Steak Knives, quite simply the best there is. Sleekly shaped and exceptionally balanced, these steak knives have been precision-crafted in the small French town of Laguiole since 1829. A French country tradition, they’re distinguished by the gentle curve of the razor-sharp stainless steel blade and contoured elongated grip. The stainless steel handle is hallmarked with the signature Laguiole bee. Presented in a natural beech wood storage box. Dishwasher safe. Set of six 6 each 9L. This is crafted in 18/8 Stainless Steel. Available in other colors

  • Binding :Kitchen
  • Brand :Laguiole
  • Feature :P recision crafted in Laguiole, France
  • Feature :Stainless steel handles
  • Feature :Set of 6
  • Feature :D ishwasher safe
  • Feature :Measures 9 in. length
  • Label :D ubost
  • Manufacturer :D ubost
  • ProductGroup :Kitchen
  • ProductTypeName :HOME
  • Publisher :D ubost
  • Studio :D ubost
  • Title :Jean Dubost Laguiole 6-Piece Steak Knives (Stainless Steel
Filed under: Uncategorized No Comments
3Sep/090

4 WIDE SANDWICH SPREADER BUTTER KNIFE KNIVES SET RESTAURANT GRADE


Quality-built with extra attention paid to every detail. These butter knives feature stainless steel blades, brass rivets and smooth easy to grip wood handles.

Dimensions:

Overall length: 7.5

Blade length: 3.75

Blade width: 1.25 (at widest)

  • Brand :Update International
  • EAN :0842390013228
  • Feature :Set of 4 sturdy commercial quality spreaders
  • Feature :Ideal for spreading butter on bread, corn, etc.
  • Feature :Also great for spreads, chicken salad, tuna salad, cream cheese
  • Label :Update International
  • Manufacturer :Update International
  • MPN :UP-WS-6
  • ProductGroup :Kitchen
  • ProductTypeName :KITCHEN
  • Publisher :Update International
  • Studio :Update International
  • Title :4 WIDE SANDWICH SPREADER BUTTER KNIFE KNIVES SET RESTAURANT GRADE
  • UPC :842390013228
Filed under: Uncategorized No Comments
Page 2 of 61235...Last »
Get Adobe Flash playerPlugin by wpburn.com wordpress themes