Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. about file type

about file type

Scheduled Pinned Locked Moved ASP.NET
designhelp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    amir_iiui
    wrote on last edited by
    #1

    i am using following code behind a push button..... Response.ContentType = "application/vnd.ms-excel"; this.EnableViewState = false; Response.Charset = String.Empty; System.IO.StringWriter myTextWriter =new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter myHtmlTextWriter = new System.Web.UI.HtmlTextWriter(myTextWriter); this.datagrid1.RenderControl(myHtmlTextWriter); Response.Write(myTextWriter.ToString()); Response.End(); now on runtime , when i pushes the button, then a dialog (window save dialog) appears, asking me, about the name which i want to give the saving file. This dialog shows name of application as default name of saving file. I want that the default name shown in the save dialog should be name of application plus the current date. Can some body help me in this way.....

    M 1 Reply Last reply
    0
    • A amir_iiui

      i am using following code behind a push button..... Response.ContentType = "application/vnd.ms-excel"; this.EnableViewState = false; Response.Charset = String.Empty; System.IO.StringWriter myTextWriter =new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter myHtmlTextWriter = new System.Web.UI.HtmlTextWriter(myTextWriter); this.datagrid1.RenderControl(myHtmlTextWriter); Response.Write(myTextWriter.ToString()); Response.End(); now on runtime , when i pushes the button, then a dialog (window save dialog) appears, asking me, about the name which i want to give the saving file. This dialog shows name of application as default name of saving file. I want that the default name shown in the save dialog should be name of application plus the current date. Can some body help me in this way.....

      M Offline
      M Offline
      minhpc_bk
      wrote on last edited by
      #2

      Hi there, In this case, you should use the Content-Disposition header field, and you can make use of the filename parameter to suggest a name that will be displayed in the File Download dialog box on the client side. The sample code is something look like this:

      string suggestedName = Your Application Name + Current Date;

      Response.AddHeader("Content-Disposition", "attachment; filename=" + suggestedName + ";");

      A 1 Reply Last reply
      0
      • M minhpc_bk

        Hi there, In this case, you should use the Content-Disposition header field, and you can make use of the filename parameter to suggest a name that will be displayed in the File Download dialog box on the client side. The sample code is something look like this:

        string suggestedName = Your Application Name + Current Date;

        Response.AddHeader("Content-Disposition", "attachment; filename=" + suggestedName + ";");

        A Offline
        A Offline
        amir_iiui
        wrote on last edited by
        #3

        it worked fine..... thankx...

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups