Click here to Skip to main content
15,909,030 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I'm creating a web page with a download option

when the user clicks the the download option he gets three options

   -Open
   -Save
   -Save As

I just want the user to see

   -Open

I'm using ASP.NET 4
-Thank You

p.s. i tried Google but no good
Posted
Comments
Thanks7872 23-Sep-13 2:25am    
What a bad non question. What you mean by tried google but no good? You even not mentioned what are those open,save,save as? If you just want your user to see open,why you have written other two? Why don't you remove it?

Before posting question here,be with concrete details. We are not smart enough to guess whole application. If you expect help from others than its necessary that you show some effort.

Hi,
Add this meta tag
HTML
<meta name="DownloadOptions" content="nosave" />

Try it...

[Update]

C#
Response.AddHeader("Content-Disposition", "attachment;filename=pipo.html");
Response.AddHeader("X-Download-Options", "noopen");
 
Share this answer
 
v4
I found the solution

Web Page

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace DisableSave
{
    public partial class webpage: System.Web.UI.Page
    {

        private bool disableOpen;
        private bool disableSave;

        public bool DisableOpen
        {
            get { return disableOpen; }
            set { disableOpen = value; }
        }

        public bool DisableSave
        {
            get { return disableSave; }
            set { disableSave = value; }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            DisableSave = true;

            if (Page is webpage&& (((webpage)Page).DisableOpen || ((webpage)Page).DisableSave))
            {
                // Build the HTML meta tag
                HtmlMeta meta = new HtmlMeta();
                meta.Name = "DownloadOptions";

                if (((webpage)Page).DisableOpen)
                {
                    // Disable the open button
                    meta.Content = "noopen";
                }
                if (((webpage)Page).DisableSave)
                {
                    // Disable the save button
                    meta.Content = "nosave";
                }

                // Add the meta tag to the page
                Page.Header.Controls.Add(meta);

            }
        }

        protected void btn1_Click(object sender, EventArgs e)
        {            
            Response.ClearContent();
            Response.ClearHeaders();
            Response.AddHeader("Content-Type", "text/plain");
            Response.AddHeader("Content-Disposition", "attachment; filename=\"text.txt\"");
            Response.TransmitFile("text.txt");
            Response.End();
        }
    }
}


Master Page
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace DisableSave
{
    public partial class Site : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page is webpage && (((webpage)Page).DisableOpen || ((webpage)Page).DisableSave))
            {
                // Build the HTML meta tag
                HtmlMeta meta = new HtmlMeta();
                meta.Name = "DownloadOptions";

                if (((webpage)Page).DisableOpen)
                {
                    // Disable the open button
                    meta.Content = "noopen";
                }
                if (((webpage)Page).DisableSave)
                {
                    // Disable the save button
                    meta.Content = "nosave";
                }

                // Add the meta tag to the page
                Page.Header.Controls.Add(meta);
            }
        }
    }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900