how to open a file and save it local

Discussion in 'ASP .Net' started by ton, Sep 3, 2009.

  1. ton

    ton Guest

    Hi

    In my app I create an file. I want the user to save this file on the loca
    drive (c:\temp). Once saved the user can open Word and use this file as a
    merge file so a letter can be generated.

    How can this be doen with ASP (vb2005) & javascript

    thanx

    ton
     
    ton, Sep 3, 2009
    #1
    1. Advertising

  2. On Sep 3, 11:13 am, "ton" <> wrote:
    > Hi
    >
    > In my app I create an file. I want the user to save this file on the loca
    > drive (c:\temp). Once saved the user can open Word and use this file as a
    > merge file so a letter can be generated.
    >
    > How can this be doen with ASP (vb2005) & javascript
    >
    > thanx
    >
    > ton


    You can't save it like this but you can open it directly on the client
    and then user can save it in Word

    Try to test

    Response.Buffer=true;
    Response.ContentType = "application/vnd.ms-word";
    Response.AddHeader("Content-Disposition",
    "attachment;Filename=document.doc");
    Response.Write("some text");
    Response.Flush();
    Response.End();

    It should show a popup message to Save/Open the file

    Hope this helps
     
    Alexey Smirnov, Sep 3, 2009
    #2
    1. Advertising

  3. What type of file a word doc?

    create a ashx page (Generic handler) not a aspx page, something like this



    Imports System.Web
    Imports System.Web.Services

    Public Class word
    Implements System.Web.IHttpHandler

    Sub ProcessRequest(ByVal context As HttpContext) Implements
    IHttpHandler.ProcessRequest

    context.Response.ContentType = "application/msword"
    context.Response.AddHeader("content-disposition",
    "attachment;filename=yourdoc.doc")
    context.Response.Write("Hello World!")

    End Sub

    ReadOnly Property IsReusable() As Boolean Implements
    IHttpHandler.IsReusable
    Get
    Return False
    End Get
    End Property

    End Class




    "ton" <> wrote in message
    news:9eef7$4a9f888a$541ee3e6$1.nb.home.nl...
    > Hi
    >
    > In my app I create an file. I want the user to save this file on the loca
    > drive (c:\temp). Once saved the user can open Word and use this file as a
    > merge file so a letter can be generated.
    >
    > How can this be doen with ASP (vb2005) & javascript
    >
    > thanx
    >
    > ton
    >
     
    ThatsIT.net.au, Sep 3, 2009
    #3
  4. ton

    ton Guest

    no it will be a delimited file to use in a mailmerge with a standerd word
    doc

    "ThatsIT.net.au" <me@work> schreef in bericht
    news:...
    > What type of file a word doc?
    >
    > create a ashx page (Generic handler) not a aspx page, something like this
    >
    >
    >
    > Imports System.Web
    > Imports System.Web.Services
    >
    > Public Class word
    > Implements System.Web.IHttpHandler
    >
    > Sub ProcessRequest(ByVal context As HttpContext) Implements
    > IHttpHandler.ProcessRequest
    >
    > context.Response.ContentType = "application/msword"
    > context.Response.AddHeader("content-disposition",
    > "attachment;filename=yourdoc.doc")
    > context.Response.Write("Hello World!")
    >
    > End Sub
    >
    > ReadOnly Property IsReusable() As Boolean Implements
    > IHttpHandler.IsReusable
    > Get
    > Return False
    > End Get
    > End Property
    >
    > End Class
    >
    >
    >
    >
    > "ton" <> wrote in message
    > news:9eef7$4a9f888a$541ee3e6$1.nb.home.nl...
    >> Hi
    >>
    >> In my app I create an file. I want the user to save this file on the loca
    >> drive (c:\temp). Once saved the user can open Word and use this file as a
    >> merge file so a letter can be generated.
    >>
    >> How can this be doen with ASP (vb2005) & javascript
    >>
    >> thanx
    >>
    >> ton
    >>

    >
     
    ton, Sep 3, 2009
    #4
  5. change

    context.Response.ContentType = "application/msword"
    context.Response.AddHeader("content-disposition", attachment;filename=yourdoc.doc")

    to

    context.Response.ContentType = "text/csv"
    context.Response.AddHeader("content-disposition", attachment;filename=yourdoc.csv")





    "ton" <> wrote in message news:cb10b$4a9f93ea$541ee3e6$1.nb.home.nl...
    > no it will be a delimited file to use in a mailmerge with a standerd word
    > doc
    >
    > "ThatsIT.net.au" <me@work> schreef in bericht
    > news:...
    >> What type of file a word doc?
    >>
    >> create a ashx page (Generic handler) not a aspx page, something like this
    >>
    >>
    >>
    >> Imports System.Web
    >> Imports System.Web.Services
    >>
    >> Public Class word
    >> Implements System.Web.IHttpHandler
    >>
    >> Sub ProcessRequest(ByVal context As HttpContext) Implements
    >> IHttpHandler.ProcessRequest
    >>
    >> context.Response.ContentType = "application/msword"
    >> context.Response.AddHeader("content-disposition",
    >> "attachment;filename=yourdoc.doc")
    >> context.Response.Write("Hello World!")
    >>
    >> End Sub
    >>
    >> ReadOnly Property IsReusable() As Boolean Implements
    >> IHttpHandler.IsReusable
    >> Get
    >> Return False
    >> End Get
    >> End Property
    >>
    >> End Class
    >>
    >>
    >>
    >>
    >> "ton" <> wrote in message
    >> news:9eef7$4a9f888a$541ee3e6$1.nb.home.nl...
    >>> Hi
    >>>
    >>> In my app I create an file. I want the user to save this file on the loca
    >>> drive (c:\temp). Once saved the user can open Word and use this file as a
    >>> merge file so a letter can be generated.
    >>>
    >>> How can this be doen with ASP (vb2005) & javascript
    >>>
    >>> thanx
    >>>
    >>> ton
    >>>

    >>

    >
     
    ThatsIT.net.au, Sep 3, 2009
    #5
  6. ton

    ton Guest

    I do not know what you mean.
    Your suggestion is that I should add a file to my solution (ashx): I did this and then?

    <%@ WebHandler Language="VB" Class="word" %>

    Imports System

    Imports System.Web

    Public Class word : Implements IHttpHandler


    Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest

    context.Response.ContentType = "text/csv"

    context.Response.AddHeader("content-disposition", "attachment;filename=yourdoc.csv")

    context.Response.Write("Hello World!")

    End Sub


    Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable

    Get

    Return False

    End Get

    End Property

    End Class

    What should I do with it?

    thanx
    "ThatsIT.net.au" <me@work> schreef in bericht news:...
    change

    context.Response.ContentType = "application/msword"
    context.Response.AddHeader("content-disposition", attachment;filename=yourdoc.doc")

    to

    context.Response.ContentType = "text/csv"
    context.Response.AddHeader("content-disposition", attachment;filename=yourdoc.csv")





    "ton" <> wrote in message news:cb10b$4a9f93ea$541ee3e6$1.nb.home.nl...
    > no it will be a delimited file to use in a mailmerge with a standerd word
    > doc
    >
    > "ThatsIT.net.au" <me@work> schreef in bericht
    > news:...
    >> What type of file a word doc?
    >>
    >> create a ashx page (Generic handler) not a aspx page, something like this
    >>
    >>
    >>
    >> Imports System.Web
    >> Imports System.Web.Services
    >>
    >> Public Class word
    >> Implements System.Web.IHttpHandler
    >>
    >> Sub ProcessRequest(ByVal context As HttpContext) Implements
    >> IHttpHandler.ProcessRequest
    >>
    >> context.Response.ContentType = "application/msword"
    >> context.Response.AddHeader("content-disposition",
    >> "attachment;filename=yourdoc.doc")
    >> context.Response.Write("Hello World!")
    >>
    >> End Sub
    >>
    >> ReadOnly Property IsReusable() As Boolean Implements
    >> IHttpHandler.IsReusable
    >> Get
    >> Return False
    >> End Get
    >> End Property
    >>
    >> End Class
    >>
    >>
    >>
    >>
    >> "ton" <> wrote in message
    >> news:9eef7$4a9f888a$541ee3e6$1.nb.home.nl...
    >>> Hi
    >>>
    >>> In my app I create an file. I want the user to save this file on the loca
    >>> drive (c:\temp). Once saved the user can open Word and use this file as a
    >>> merge file so a letter can be generated.
    >>>
    >>> How can this be doen with ASP (vb2005) & javascript
    >>>
    >>> thanx
    >>>
    >>> ton
    >>>

    >>

    >
     
    ton, Sep 3, 2009
    #6
  7. Are you using visual studio?

    if so add a ashx page, called generic handler in the menu


    then all you need is to add 3 lines, 5the last line will write you data. ashx page is much like a aspx page but dose not include a load of stuff needed for a web page. its used for displaying other file types such as a csv file


    context.Response.ContentType = "text/csv"

    context.Response.AddHeader("content-disposition", "attachment;filename=yourdoc.csv")

    context.Response.Write("Hello World!")




    "ton" <> wrote in message news:bf418$4a9f98f7$541ee3e6$1.nb.home.nl...
    I do not know what you mean.
    Your suggestion is that I should add a file to my solution (ashx): I did this and then?

    <%@ WebHandler Language="VB" Class="word" %>

    Imports System

    Imports System.Web

    Public Class word : Implements IHttpHandler


    Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest

    context.Response.ContentType = "text/csv"

    context.Response.AddHeader("content-disposition", "attachment;filename=yourdoc.csv")

    context.Response.Write("Hello World!")

    End Sub


    Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable

    Get

    Return False

    End Get

    End Property

    End Class

    What should I do with it?

    thanx
    "ThatsIT.net.au" <me@work> schreef in bericht news:...
    change

    context.Response.ContentType = "application/msword"
    context.Response.AddHeader("content-disposition", attachment;filename=yourdoc.doc")

    to

    context.Response.ContentType = "text/csv"
    context.Response.AddHeader("content-disposition", attachment;filename=yourdoc.csv")





    "ton" <> wrote in message news:cb10b$4a9f93ea$541ee3e6$1.nb.home.nl...
    > no it will be a delimited file to use in a mailmerge with a standerd word
    > doc
    >
    > "ThatsIT.net.au" <me@work> schreef in bericht
    > news:...
    >> What type of file a word doc?
    >>
    >> create a ashx page (Generic handler) not a aspx page, something like this
    >>
    >>
    >>
    >> Imports System.Web
    >> Imports System.Web.Services
    >>
    >> Public Class word
    >> Implements System.Web.IHttpHandler
    >>
    >> Sub ProcessRequest(ByVal context As HttpContext) Implements
    >> IHttpHandler.ProcessRequest
    >>
    >> context.Response.ContentType = "application/msword"
    >> context.Response.AddHeader("content-disposition",
    >> "attachment;filename=yourdoc.doc")
    >> context.Response.Write("Hello World!")
    >>
    >> End Sub
    >>
    >> ReadOnly Property IsReusable() As Boolean Implements
    >> IHttpHandler.IsReusable
    >> Get
    >> Return False
    >> End Get
    >> End Property
    >>
    >> End Class
    >>
    >>
    >>
    >>
    >> "ton" <> wrote in message
    >> news:9eef7$4a9f888a$541ee3e6$1.nb.home.nl...
    >>> Hi
    >>>
    >>> In my app I create an file. I want the user to save this file on the loca
    >>> drive (c:\temp). Once saved the user can open Word and use this file as a
    >>> merge file so a letter can be generated.
    >>>
    >>> How can this be doen with ASP (vb2005) & javascript
    >>>
    >>> thanx
    >>>
    >>> ton
    >>>

    >>

    >
     
    ThatsIT.net.au, Sep 3, 2009
    #7
  8. On Sep 3, 12:23 pm, "ton" <> wrote:
    > I do not know what you mean.
    > Your suggestion is that I should add a file to my solution (ashx): I did this and then?
    >


    Using ASHX means you should link to that file from your page. When
    user clicked on that link the file will be opened. So you need to add
    a hyperlink

    <a href="file.ashx">Click to open Word</a>
     
    Alexey Smirnov, Sep 3, 2009
    #8
  9. ton

    ton Guest

    I'm sorry. I do use visual studio and I have added your file. But it is a ASP appllication which after clicking by the users will end in creating the txt file. This file is forst stored on the server but then. What should I do next. I still see no place where and how to use the ashx file


    thanx
    "ThatsIT.net.au" <me@work> schreef in bericht news:...
    Are you using visual studio?

    if so add a ashx page, called generic handler in the menu


    then all you need is to add 3 lines, 5the last line will write you data. ashx page is much like a aspx page but dose not include a load of stuff needed for a web page. its used for displaying other file types such as a csv file


    context.Response.ContentType = "text/csv"

    context.Response.AddHeader("content-disposition", "attachment;filename=yourdoc.csv")

    context.Response.Write("Hello World!")




    "ton" <> wrote in message news:bf418$4a9f98f7$541ee3e6$1.nb.home.nl...
    I do not know what you mean.
    Your suggestion is that I should add a file to my solution (ashx): I did this and then?

    <%@ WebHandler Language="VB" Class="word" %>

    Imports System

    Imports System.Web

    Public Class word : Implements IHttpHandler


    Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest

    context.Response.ContentType = "text/csv"

    context.Response.AddHeader("content-disposition", "attachment;filename=yourdoc.csv")

    context.Response.Write("Hello World!")

    End Sub


    Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable

    Get

    Return False

    End Get

    End Property

    End Class

    What should I do with it?

    thanx
    "ThatsIT.net.au" <me@work> schreef in bericht news:...
    change

    context.Response.ContentType = "application/msword"
    context.Response.AddHeader("content-disposition", attachment;filename=yourdoc.doc")

    to

    context.Response.ContentType = "text/csv"
    context.Response.AddHeader("content-disposition", attachment;filename=yourdoc.csv")





    "ton" <> wrote in message news:cb10b$4a9f93ea$541ee3e6$1.nb.home.nl...
    > no it will be a delimited file to use in a mailmerge with a standerd word
    > doc
    >
    > "ThatsIT.net.au" <me@work> schreef in bericht
    > news:...
    >> What type of file a word doc?
    >>
    >> create a ashx page (Generic handler) not a aspx page, something like this
    >>
    >>
    >>
    >> Imports System.Web
    >> Imports System.Web.Services
    >>
    >> Public Class word
    >> Implements System.Web.IHttpHandler
    >>
    >> Sub ProcessRequest(ByVal context As HttpContext) Implements
    >> IHttpHandler.ProcessRequest
    >>
    >> context.Response.ContentType = "application/msword"
    >> context.Response.AddHeader("content-disposition",
    >> "attachment;filename=yourdoc.doc")
    >> context.Response.Write("Hello World!")
    >>
    >> End Sub
    >>
    >> ReadOnly Property IsReusable() As Boolean Implements
    >> IHttpHandler.IsReusable
    >> Get
    >> Return False
    >> End Get
    >> End Property
    >>
    >> End Class
    >>
    >>
    >>
    >>
    >> "ton" <> wrote in message
    >> news:9eef7$4a9f888a$541ee3e6$1.nb.home.nl...
    >>> Hi
    >>>
    >>> In my app I create an file. I want the user to save this file on the loca
    >>> drive (c:\temp). Once saved the user can open Word and use this file as a
    >>> merge file so a letter can be generated.
    >>>
    >>> How can this be doen with ASP (vb2005) & javascript
    >>>
    >>> thanx
    >>>
    >>> ton
    >>>

    >>

    >
     
    ton, Sep 3, 2009
    #9
  10. I guess we better make sure were reading from the same page
    a few quick questions, ill be watching for your answers so we can move quick

    You already have code that creates a txt file?

    you have all ready saved it on the server?

    if so what name did you give it, did you save it as blah.csv ?

    try navigating to the ashx file and tell me what happens


    "ton" <> wrote in message news:f2468$4a9fb5d3$541ee3e6$1.nb.home.nl...
    I'm sorry. I do use visual studio and I have added your file. But it is a ASP appllication which after clicking by the users will end in creating the txt file. This file is forst stored on the server but then. What should I do next. I still see no place where and how to use the ashx file


    thanx
    "ThatsIT.net.au" <me@work> schreef in bericht news:...
    Are you using visual studio?

    if so add a ashx page, called generic handler in the menu


    then all you need is to add 3 lines, 5the last line will write you data. ashx page is much like a aspx page but dose not include a load of stuff needed for a web page. its used for displaying other file types such as a csv file


    context.Response.ContentType = "text/csv"

    context.Response.AddHeader("content-disposition", "attachment;filename=yourdoc.csv")

    context.Response.Write("Hello World!")




    "ton" <> wrote in message news:bf418$4a9f98f7$541ee3e6$1.nb.home.nl...
    I do not know what you mean.
    Your suggestion is that I should add a file to my solution (ashx): I did this and then?

    <%@ WebHandler Language="VB" Class="word" %>

    Imports System

    Imports System.Web

    Public Class word : Implements IHttpHandler


    Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest

    context.Response.ContentType = "text/csv"

    context.Response.AddHeader("content-disposition", "attachment;filename=yourdoc.csv")

    context.Response.Write("Hello World!")

    End Sub


    Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable

    Get

    Return False

    End Get

    End Property

    End Class

    What should I do with it?

    thanx
    "ThatsIT.net.au" <me@work> schreef in bericht news:...
    change

    context.Response.ContentType = "application/msword"
    context.Response.AddHeader("content-disposition", attachment;filename=yourdoc.doc")

    to

    context.Response.ContentType = "text/csv"
    context.Response.AddHeader("content-disposition", attachment;filename=yourdoc.csv")





    "ton" <> wrote in message news:cb10b$4a9f93ea$541ee3e6$1.nb.home.nl...
    > no it will be a delimited file to use in a mailmerge with a standerd word
    > doc
    >
    > "ThatsIT.net.au" <me@work> schreef in bericht
    > news:...
    >> What type of file a word doc?
    >>
    >> create a ashx page (Generic handler) not a aspx page, something like this
    >>
    >>
    >>
    >> Imports System.Web
    >> Imports System.Web.Services
    >>
    >> Public Class word
    >> Implements System.Web.IHttpHandler
    >>
    >> Sub ProcessRequest(ByVal context As HttpContext) Implements
    >> IHttpHandler.ProcessRequest
    >>
    >> context.Response.ContentType = "application/msword"
    >> context.Response.AddHeader("content-disposition",
    >> "attachment;filename=yourdoc.doc")
    >> context.Response.Write("Hello World!")
    >>
    >> End Sub
    >>
    >> ReadOnly Property IsReusable() As Boolean Implements
    >> IHttpHandler.IsReusable
    >> Get
    >> Return False
    >> End Get
    >> End Property
    >>
    >> End Class
    >>
    >>
    >>
    >>
    >> "ton" <> wrote in message
    >> news:9eef7$4a9f888a$541ee3e6$1.nb.home.nl...
    >>> Hi
    >>>
    >>> In my app I create an file. I want the user to save this file on the loca
    >>> drive (c:\temp). Once saved the user can open Word and use this file as a
    >>> merge file so a letter can be generated.
    >>>
    >>> How can this be doen with ASP (vb2005) & javascript
    >>>
    >>> thanx
    >>>
    >>> ton
    >>>

    >>

    >
     
    ThatsIT.net.au, Sep 3, 2009
    #10
  11. ton

    ton Guest

    what do you mean navigating to the ashx file. The webpage shows information about customer data, with textboxes, dropdownlist, buttons and so on. Pressing on the "sendletter button" creates a csv or text file whatever. It is this file I want to promt to the user so he can save it. After opening word and choosing the correct template this file will be used in the merge.

    Other questions are in your message

    Thanx
    "ThatsIT.net.au" <me@work> schreef in bericht news:D...
    I guess we better make sure were reading from the same page
    a few quick questions, ill be watching for your answers so we can move quick

    You already have code that creates a txt file? YES

    you have all ready saved it on the server? YES

    if so what name did you give it, did you save it as blah.csv ? YES

    try navigating to the ashx file and tell me what happens


    "ton" <> wrote in message news:f2468$4a9fb5d3$541ee3e6$1.nb.home.nl...
    I'm sorry. I do use visual studio and I have added your file. But it is a ASP appllication which after clicking by the users will end in creating the txt file. This file is forst stored on the server but then. What should I do next. I still see no place where and how to use the ashx file


    thanx
    "ThatsIT.net.au" <me@work> schreef in bericht news:...
    Are you using visual studio?

    if so add a ashx page, called generic handler in the menu


    then all you need is to add 3 lines, 5the last line will write you data. ashx page is much like a aspx page but dose not include a load of stuff needed for a web page. its used for displaying other file types such as a csv file


    context.Response.ContentType = "text/csv"

    context.Response.AddHeader("content-disposition", "attachment;filename=yourdoc.csv")

    context.Response.Write("Hello World!")




    "ton" <> wrote in message news:bf418$4a9f98f7$541ee3e6$1.nb.home.nl...
    I do not know what you mean.
    Your suggestion is that I should add a file to my solution (ashx): I did this and then?

    <%@ WebHandler Language="VB" Class="word" %>

    Imports System

    Imports System.Web

    Public Class word : Implements IHttpHandler


    Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest

    context.Response.ContentType = "text/csv"

    context.Response.AddHeader("content-disposition", "attachment;filename=yourdoc.csv")

    context.Response.Write("Hello World!")

    End Sub


    Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable

    Get

    Return False

    End Get

    End Property

    End Class

    What should I do with it?

    thanx
    "ThatsIT.net.au" <me@work> schreef in bericht news:...
    change

    context.Response.ContentType = "application/msword"
    context.Response.AddHeader("content-disposition", attachment;filename=yourdoc.doc")

    to

    context.Response.ContentType = "text/csv"
    context.Response.AddHeader("content-disposition", attachment;filename=yourdoc.csv")





    "ton" <> wrote in message news:cb10b$4a9f93ea$541ee3e6$1.nb.home.nl...
    > no it will be a delimited file to use in a mailmerge with a standerd word
    > doc
    >
    > "ThatsIT.net.au" <me@work> schreef in bericht
    > news:...
    >> What type of file a word doc?
    >>
    >> create a ashx page (Generic handler) not a aspx page, something like this
    >>
    >>
    >>
    >> Imports System.Web
    >> Imports System.Web.Services
    >>
    >> Public Class word
    >> Implements System.Web.IHttpHandler
    >>
    >> Sub ProcessRequest(ByVal context As HttpContext) Implements
    >> IHttpHandler.ProcessRequest
    >>
    >> context.Response.ContentType = "application/msword"
    >> context.Response.AddHeader("content-disposition",
    >> "attachment;filename=yourdoc.doc")
    >> context.Response.Write("Hello World!")
    >>
    >> End Sub
    >>
    >> ReadOnly Property IsReusable() As Boolean Implements
    >> IHttpHandler.IsReusable
    >> Get
    >> Return False
    >> End Get
    >> End Property
    >>
    >> End Class
    >>
    >>
    >>
    >>
    >> "ton" <> wrote in message
    >> news:9eef7$4a9f888a$541ee3e6$1.nb.home.nl...
    >>> Hi
    >>>
    >>> In my app I create an file. I want the user to save this file on the loca
    >>> drive (c:\temp). Once saved the user can open Word and use this file as a
    >>> merge file so a letter can be generated.
    >>>
    >>> How can this be doen with ASP (vb2005) & javascript
    >>>
    >>> thanx
    >>>
    >>> ton
    >>>

    >>

    >
     
    ton, Sep 3, 2009
    #11
  12. sorry I did not get straight back as promised I had a long phone call

    will give you the code in a minute or 2



    "ton" <> wrote in message news:251dc$4a9fca41$541ee3e6$1.nb.home.nl...
    what do you mean navigating to the ashx file. The webpage shows information about customer data, with textboxes, dropdownlist, buttons and so on. Pressing on the "sendletter button" creates a csv or text file whatever. It is this file I want to promt to the user so he can save it. After opening word and choosing the correct template this file will be used in the merge.

    Other questions are in your message

    Thanx
    "ThatsIT.net.au" <me@work> schreef in bericht news:D...
    I guess we better make sure were reading from the same page
    a few quick questions, ill be watching for your answers so we can move quick

    You already have code that creates a txt file? YES

    you have all ready saved it on the server? YES

    if so what name did you give it, did you save it as blah.csv ? YES

    try navigating to the ashx file and tell me what happens


    "ton" <> wrote in message news:f2468$4a9fb5d3$541ee3e6$1.nb.home.nl...
    I'm sorry. I do use visual studio and I have added your file. But it is a ASP appllication which after clicking by the users will end in creating the txt file. This file is forst stored on the server but then. What should I do next. I still see no place where and how to use the ashx file


    thanx
    "ThatsIT.net.au" <me@work> schreef in bericht news:...
    Are you using visual studio?

    if so add a ashx page, called generic handler in the menu


    then all you need is to add 3 lines, 5the last line will write you data. ashx page is much like a aspx page but dose not include a load of stuff needed for a web page. its used for displaying other file types such as a csv file


    context.Response.ContentType = "text/csv"

    context.Response.AddHeader("content-disposition", "attachment;filename=yourdoc.csv")

    context.Response.Write("Hello World!")




    "ton" <> wrote in message news:bf418$4a9f98f7$541ee3e6$1.nb.home.nl...
    I do not know what you mean.
    Your suggestion is that I should add a file to my solution (ashx): I did this and then?

    <%@ WebHandler Language="VB" Class="word" %>

    Imports System

    Imports System.Web

    Public Class word : Implements IHttpHandler


    Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest

    context.Response.ContentType = "text/csv"

    context.Response.AddHeader("content-disposition", "attachment;filename=yourdoc.csv")

    context.Response.Write("Hello World!")

    End Sub


    Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable

    Get

    Return False

    End Get

    End Property

    End Class

    What should I do with it?

    thanx
    "ThatsIT.net.au" <me@work> schreef in bericht news:...
    change

    context.Response.ContentType = "application/msword"
    context.Response.AddHeader("content-disposition", attachment;filename=yourdoc.doc")

    to

    context.Response.ContentType = "text/csv"
    context.Response.AddHeader("content-disposition", attachment;filename=yourdoc.csv")





    "ton" <> wrote in message news:cb10b$4a9f93ea$541ee3e6$1.nb.home.nl...
    > no it will be a delimited file to use in a mailmerge with a standerd word
    > doc
    >
    > "ThatsIT.net.au" <me@work> schreef in bericht
    > news:...
    >> What type of file a word doc?
    >>
    >> create a ashx page (Generic handler) not a aspx page, something like this
    >>
    >>
    >>
    >> Imports System.Web
    >> Imports System.Web.Services
    >>
    >> Public Class word
    >> Implements System.Web.IHttpHandler
    >>
    >> Sub ProcessRequest(ByVal context As HttpContext) Implements
    >> IHttpHandler.ProcessRequest
    >>
    >> context.Response.ContentType = "application/msword"
    >> context.Response.AddHeader("content-disposition",
    >> "attachment;filename=yourdoc.doc")
    >> context.Response.Write("Hello World!")
    >>
    >> End Sub
    >>
    >> ReadOnly Property IsReusable() As Boolean Implements
    >> IHttpHandler.IsReusable
    >> Get
    >> Return False
    >> End Get
    >> End Property
    >>
    >> End Class
    >>
    >>
    >>
    >>
    >> "ton" <> wrote in message
    >> news:9eef7$4a9f888a$541ee3e6$1.nb.home.nl...
    >>> Hi
    >>>
    >>> In my app I create an file. I want the user to save this file on the loca
    >>> drive (c:\temp). Once saved the user can open Word and use this file as a
    >>> merge file so a letter can be generated.
    >>>
    >>> How can this be doen with ASP (vb2005) & javascript
    >>>
    >>> thanx
    >>>
    >>> ton
    >>>

    >>

    >
     
    ThatsIT.net.au, Sep 3, 2009
    #12
  13. change path to fiole to suit

    replace previous 3 lines of code with





    context.Response.ContentType = "text/csv"

    context.Response.AddHeader("content-disposition", "attachment;filename=yourdoc.csv")

    Dim csvFile As IO.FileInfo = New IO.FileInfo(context.Server.MapPath("\yourfolder\yourfile.csv"))

    Dim sr As IO.StreamReader = csvFile .OpenText

    context.Response.Write(sr.ReadToEnd)





    "ThatsIT.net.au" <me@work> wrote in message news:...
    sorry I did not get straight back as promised I had a long phone call

    will give you the code in a minute or 2



    "ton" <> wrote in message news:251dc$4a9fca41$541ee3e6$1.nb.home.nl...
    what do you mean navigating to the ashx file. The webpage shows information about customer data, with textboxes, dropdownlist, buttons and so on. Pressing on the "sendletter button" creates a csv or text file whatever. It is this file I want to promt to the user so he can save it. After opening word and choosing the correct template this file will be used in the merge.

    Other questions are in your message

    Thanx
    "ThatsIT.net.au" <me@work> schreef in bericht news:D...
    I guess we better make sure were reading from the same page
    a few quick questions, ill be watching for your answers so we can move quick

    You already have code that creates a txt file? YES

    you have all ready saved it on the server? YES

    if so what name did you give it, did you save it as blah.csv ? YES

    try navigating to the ashx file and tell me what happens


    "ton" <> wrote in message news:f2468$4a9fb5d3$541ee3e6$1.nb.home.nl...
    I'm sorry. I do use visual studio and I have added your file. But it is a ASP appllication which after clicking by the users will end in creating the txt file. This file is forst stored on the server but then. What should I do next. I still see no place where and how to use the ashx file


    thanx
    "ThatsIT.net.au" <me@work> schreef in bericht news:...
    Are you using visual studio?

    if so add a ashx page, called generic handler in the menu


    then all you need is to add 3 lines, 5the last line will write you data. ashx page is much like a aspx page but dose not include a load of stuff needed for a web page. its used for displaying other file types such as a csv file


    context.Response.ContentType = "text/csv"

    context.Response.AddHeader("content-disposition", "attachment;filename=yourdoc.csv")

    context.Response.Write("Hello World!")




    "ton" <> wrote in message news:bf418$4a9f98f7$541ee3e6$1.nb.home.nl...
    I do not know what you mean.
    Your suggestion is that I should add a file to my solution (ashx): I did this and then?

    <%@ WebHandler Language="VB" Class="word" %>

    Imports System

    Imports System.Web

    Public Class word : Implements IHttpHandler


    Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest

    context.Response.ContentType = "text/csv"

    context.Response.AddHeader("content-disposition", "attachment;filename=yourdoc.csv")

    context.Response.Write("Hello World!")

    End Sub


    Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable

    Get

    Return False

    End Get

    End Property

    End Class

    What should I do with it?

    thanx
    "ThatsIT.net.au" <me@work> schreef in bericht news:...
    change

    context.Response.ContentType = "application/msword"
    context.Response.AddHeader("content-disposition", attachment;filename=yourdoc.doc")

    to

    context.Response.ContentType = "text/csv"
    context.Response.AddHeader("content-disposition", attachment;filename=yourdoc.csv")





    "ton" <> wrote in message news:cb10b$4a9f93ea$541ee3e6$1.nb.home.nl...
    > no it will be a delimited file to use in a mailmerge with a standerd word
    > doc
    >
    > "ThatsIT.net.au" <me@work> schreef in bericht
    > news:...
    >> What type of file a word doc?
    >>
    >> create a ashx page (Generic handler) not a aspx page, something like this
    >>
    >>
    >>
    >> Imports System.Web
    >> Imports System.Web.Services
    >>
    >> Public Class word
    >> Implements System.Web.IHttpHandler
    >>
    >> Sub ProcessRequest(ByVal context As HttpContext) Implements
    >> IHttpHandler.ProcessRequest
    >>
    >> context.Response.ContentType = "application/msword"
    >> context.Response.AddHeader("content-disposition",
    >> "attachment;filename=yourdoc.doc")
    >> context.Response.Write("Hello World!")
    >>
    >> End Sub
    >>
    >> ReadOnly Property IsReusable() As Boolean Implements
    >> IHttpHandler.IsReusable
    >> Get
    >> Return False
    >> End Get
    >> End Property
    >>
    >> End Class
    >>
    >>
    >>
    >>
    >> "ton" <> wrote in message
    >> news:9eef7$4a9f888a$541ee3e6$1.nb.home.nl...
    >>> Hi
    >>>
    >>> In my app I create an file. I want the user to save this file on the loca
    >>> drive (c:\temp). Once saved the user can open Word and use this file as a
    >>> merge file so a letter can be generated.
    >>>
    >>> How can this be doen with ASP (vb2005) & javascript
    >>>
    >>> thanx
    >>>
    >>> ton
    >>>

    >>

    >
     
    ThatsIT.net.au, Sep 3, 2009
    #13
  14. ton

    ton Guest

    I have not done it, but I still do not get it where the ashx get involved. The button procedure creates the doc file on the server and then what?
    thanx
    "ThatsIT.net.au" <me@work> schreef in bericht news:...
    change path to fiole to suit

    replace previous 3 lines of code with





    context.Response.ContentType = "text/csv"

    context.Response.AddHeader("content-disposition", "attachment;filename=yourdoc.csv")

    Dim csvFile As IO.FileInfo = New IO.FileInfo(context.Server.MapPath("\yourfolder\yourfile.csv"))

    Dim sr As IO.StreamReader = csvFile .OpenText

    context.Response.Write(sr.ReadToEnd)





    "ThatsIT.net.au" <me@work> wrote in message news:...
    sorry I did not get straight back as promised I had a long phone call

    will give you the code in a minute or 2



    "ton" <> wrote in message news:251dc$4a9fca41$541ee3e6$1.nb.home.nl...
    what do you mean navigating to the ashx file. The webpage shows information about customer data, with textboxes, dropdownlist, buttons and so on. Pressing on the "sendletter button" creates a csv or text file whatever. It is this file I want to promt to the user so he can save it. After opening word and choosing the correct template this file will be used in the merge.

    Other questions are in your message

    Thanx
    "ThatsIT.net.au" <me@work> schreef in bericht news:D...
    I guess we better make sure were reading from the same page
    a few quick questions, ill be watching for your answers so we can move quick

    You already have code that creates a txt file? YES

    you have all ready saved it on the server? YES

    if so what name did you give it, did you save it as blah.csv ? YES

    try navigating to the ashx file and tell me what happens


    "ton" <> wrote in message news:f2468$4a9fb5d3$541ee3e6$1.nb.home.nl...
    I'm sorry. I do use visual studio and I have added your file. But it is a ASP appllication which after clicking by the users will end in creating the txt file. This file is forst stored on the server but then. What should I do next. I still see no place where and how to use the ashx file


    thanx
    "ThatsIT.net.au" <me@work> schreef in bericht news:...
    Are you using visual studio?

    if so add a ashx page, called generic handler in the menu


    then all you need is to add 3 lines, 5the last line will write you data. ashx page is much like a aspx page but dose not include a load of stuff needed for a web page. its used for displaying other file types such as a csv file


    context.Response.ContentType = "text/csv"

    context.Response.AddHeader("content-disposition", "attachment;filename=yourdoc.csv")

    context.Response.Write("Hello World!")




    "ton" <> wrote in message news:bf418$4a9f98f7$541ee3e6$1.nb.home.nl...
    I do not know what you mean.
    Your suggestion is that I should add a file to my solution (ashx): I did this and then?

    <%@ WebHandler Language="VB" Class="word" %>

    Imports System

    Imports System.Web

    Public Class word : Implements IHttpHandler


    Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest

    context.Response.ContentType = "text/csv"

    context.Response.AddHeader("content-disposition", "attachment;filename=yourdoc.csv")

    context.Response.Write("Hello World!")

    End Sub


    Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable

    Get

    Return False

    End Get

    End Property

    End Class

    What should I do with it?

    thanx
    "ThatsIT.net.au" <me@work> schreef in bericht news:...
    change

    context.Response.ContentType = "application/msword"
    context.Response.AddHeader("content-disposition", attachment;filename=yourdoc.doc")

    to

    context.Response.ContentType = "text/csv"
    context.Response.AddHeader("content-disposition", attachment;filename=yourdoc.csv")





    "ton" <> wrote in message news:cb10b$4a9f93ea$541ee3e6$1.nb.home.nl...
    > no it will be a delimited file to use in a mailmerge with a standerd word
    > doc
    >
    > "ThatsIT.net.au" <me@work> schreef in bericht
    > news:...
    >> What type of file a word doc?
    >>
    >> create a ashx page (Generic handler) not a aspx page, something like this
    >>
    >>
    >>
    >> Imports System.Web
    >> Imports System.Web.Services
    >>
    >> Public Class word
    >> Implements System.Web.IHttpHandler
    >>
    >> Sub ProcessRequest(ByVal context As HttpContext) Implements
    >> IHttpHandler.ProcessRequest
    >>
    >> context.Response.ContentType = "application/msword"
    >> context.Response.AddHeader("content-disposition",
    >> "attachment;filename=yourdoc.doc")
    >> context.Response.Write("Hello World!")
    >>
    >> End Sub
    >>
    >> ReadOnly Property IsReusable() As Boolean Implements
    >> IHttpHandler.IsReusable
    >> Get
    >> Return False
    >> End Get
    >> End Property
    >>
    >> End Class
    >>
    >>
    >>
    >>
    >> "ton" <> wrote in message
    >> news:9eef7$4a9f888a$541ee3e6$1.nb.home.nl...
    >>> Hi
    >>>
    >>> In my app I create an file. I want the user to save this file on the loca
    >>> drive (c:\temp). Once saved the user can open Word and use this file as a
    >>> merge file so a letter can be generated.
    >>>
    >>> How can this be doen with ASP (vb2005) & javascript
    >>>
    >>> thanx
    >>>
    >>> ton
    >>>

    >>

    >
     
    ton, Sep 3, 2009
    #14
  15. ton

    ton Guest

    btw it is all running in an ajax updatepanel
    have not done it, but I still do not get it where the ashx get involved. The button procedure creates the doc file on the server and then what?

    thanx
    "ThatsIT.net.au" <me@work> schreef in bericht news:...
    change path to fiole to suit

    replace previous 3 lines of code with





    context.Response.ContentType = "text/csv"

    context.Response.AddHeader("content-disposition", "attachment;filename=yourdoc.csv")

    Dim csvFile As IO.FileInfo = New IO.FileInfo(context.Server.MapPath("\yourfolder\yourfile.csv"))

    Dim sr As IO.StreamReader = csvFile .OpenText

    context.Response.Write(sr.ReadToEnd)





    "ThatsIT.net.au" <me@work> wrote in message news:...
    sorry I did not get straight back as promised I had a long phone call

    will give you the code in a minute or 2



    "ton" <> wrote in message news:251dc$4a9fca41$541ee3e6$1.nb.home.nl...
    what do you mean navigating to the ashx file. The webpage shows information about customer data, with textboxes, dropdownlist, buttons and so on. Pressing on the "sendletter button" creates a csv or text file whatever. It is this file I want to promt to the user so he can save it. After opening word and choosing the correct template this file will be used in the merge.

    Other questions are in your message

    Thanx
    "ThatsIT.net.au" <me@work> schreef in bericht news:D...
    I guess we better make sure were reading from the same page
    a few quick questions, ill be watching for your answers so we can move quick

    You already have code that creates a txt file? YES

    you have all ready saved it on the server? YES

    if so what name did you give it, did you save it as blah.csv ? YES

    try navigating to the ashx file and tell me what happens


    "ton" <> wrote in message news:f2468$4a9fb5d3$541ee3e6$1.nb.home.nl...
    I'm sorry. I do use visual studio and I have added your file. But it is a ASP appllication which after clicking by the users will end in creating the txt file. This file is forst stored on the server but then. What should I do next. I still see no place where and how to use the ashx file


    thanx
    "ThatsIT.net.au" <me@work> schreef in bericht news:...
    Are you using visual studio?

    if so add a ashx page, called generic handler in the menu


    then all you need is to add 3 lines, 5the last line will write you data. ashx page is much like a aspx page but dose not include a load of stuff needed for a web page. its used for displaying other file types such as a csv file


    context.Response.ContentType = "text/csv"

    context.Response.AddHeader("content-disposition", "attachment;filename=yourdoc.csv")

    context.Response.Write("Hello World!")




    "ton" <> wrote in message news:bf418$4a9f98f7$541ee3e6$1.nb.home.nl...
    I do not know what you mean.
    Your suggestion is that I should add a file to my solution (ashx): I did this and then?

    <%@ WebHandler Language="VB" Class="word" %>

    Imports System

    Imports System.Web

    Public Class word : Implements IHttpHandler


    Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest

    context.Response.ContentType = "text/csv"

    context.Response.AddHeader("content-disposition", "attachment;filename=yourdoc.csv")

    context.Response.Write("Hello World!")

    End Sub


    Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable

    Get

    Return False

    End Get

    End Property

    End Class

    What should I do with it?

    thanx
    "ThatsIT.net.au" <me@work> schreef in bericht news:...
    change

    context.Response.ContentType = "application/msword"
    context.Response.AddHeader("content-disposition", attachment;filename=yourdoc.doc")

    to

    context.Response.ContentType = "text/csv"
    context.Response.AddHeader("content-disposition", attachment;filename=yourdoc.csv")





    "ton" <> wrote in message news:cb10b$4a9f93ea$541ee3e6$1.nb.home.nl...
    > no it will be a delimited file to use in a mailmerge with a standerd word
    > doc
    >
    > "ThatsIT.net.au" <me@work> schreef in bericht
    > news:...
    >> What type of file a word doc?
    >>
    >> create a ashx page (Generic handler) not a aspx page, something like this
    >>
    >>
    >>
    >> Imports System.Web
    >> Imports System.Web.Services
    >>
    >> Public Class word
    >> Implements System.Web.IHttpHandler
    >>
    >> Sub ProcessRequest(ByVal context As HttpContext) Implements
    >> IHttpHandler.ProcessRequest
    >>
    >> context.Response.ContentType = "application/msword"
    >> context.Response.AddHeader("content-disposition",
    >> "attachment;filename=yourdoc.doc")
    >> context.Response.Write("Hello World!")
    >>
    >> End Sub
    >>
    >> ReadOnly Property IsReusable() As Boolean Implements
    >> IHttpHandler.IsReusable
    >> Get
    >> Return False
    >> End Get
    >> End Property
    >>
    >> End Class
    >>
    >>
    >>
    >>
    >> "ton" <> wrote in message
    >> news:9eef7$4a9f888a$541ee3e6$1.nb.home.nl...
    >>> Hi
    >>>
    >>> In my app I create an file. I want the user to save this file on the loca
    >>> drive (c:\temp). Once saved the user can open Word and use this file as a
    >>> merge file so a letter can be generated.
    >>>
    >>> How can this be doen with ASP (vb2005) & javascript
    >>>
    >>> thanx
    >>>
    >>> ton
    >>>

    >>

    >
     
    ton, Sep 3, 2009
    #15
  16. ton

    ton Guest

    when adding these line in an non ajax enviroment it gives the popup dialog to open or save the file. Using it on a button within an updatepanel I get:

    sys.webforms.pagerequestmanagerparsererrorexception: the message received from the server could noy be parsed. Common causes for this error are when the rersponse is modified bij calls response.write(), response filters, httpmodules or server trace is enabled. etc

    so how about this challenge?

    I do not use the ashx file.

    any ideas?

    thanx

    ton


    "ton" <> schreef in bericht news:7638e$4a9ffb74$541ee3e6$1.nb.home.nl...
    btw it is all running in an ajax updatepanel
    have not done it, but I still do not get it where the ashx get involved. The button procedure creates the doc file on the server and then what?

    thanx
    "ThatsIT.net.au" <me@work> schreef in bericht news:...
    change path to fiole to suit

    replace previous 3 lines of code with





    context.Response.ContentType = "text/csv"

    context.Response.AddHeader("content-disposition", "attachment;filename=yourdoc.csv")

    Dim csvFile As IO.FileInfo = New IO.FileInfo(context.Server.MapPath("\yourfolder\yourfile.csv"))

    Dim sr As IO.StreamReader = csvFile .OpenText

    context.Response.Write(sr.ReadToEnd)





    "ThatsIT.net.au" <me@work> wrote in message news:...
    sorry I did not get straight back as promised I had a long phone call

    will give you the code in a minute or 2



    "ton" <> wrote in message news:251dc$4a9fca41$541ee3e6$1.nb.home.nl...
    what do you mean navigating to the ashx file. The webpage shows information about customer data, with textboxes, dropdownlist, buttons and so on. Pressing on the "sendletter button" creates a csv or text file whatever. It is this file I want to promt to the user so he can save it. After opening word and choosing the correct template this file will be used in the merge.

    Other questions are in your message

    Thanx
    "ThatsIT.net.au" <me@work> schreef in bericht news:D...
    I guess we better make sure were reading from the same page
    a few quick questions, ill be watching for your answers so we can move quick

    You already have code that creates a txt file? YES

    you have all ready saved it on the server? YES

    if so what name did you give it, did you save it as blah.csv ? YES

    try navigating to the ashx file and tell me what happens


    "ton" <> wrote in message news:f2468$4a9fb5d3$541ee3e6$1.nb.home.nl...
    I'm sorry. I do use visual studio and I have added your file. But it is a ASP appllication which after clicking by the users will end in creating the txt file. This file is forst stored on the server but then. What should I do next. I still see no place where and how to use the ashx file


    thanx
    "ThatsIT.net.au" <me@work> schreef in bericht news:...
    Are you using visual studio?

    if so add a ashx page, called generic handler in the menu


    then all you need is to add 3 lines, 5the last line will write you data. ashx page is much like a aspx page but dose not include a load of stuff needed for a web page. its used for displaying other file types such as a csv file


    context.Response.ContentType = "text/csv"

    context.Response.AddHeader("content-disposition", "attachment;filename=yourdoc.csv")

    context.Response.Write("Hello World!")




    "ton" <> wrote in message news:bf418$4a9f98f7$541ee3e6$1.nb.home.nl...
    I do not know what you mean.
    Your suggestion is that I should add a file to my solution (ashx): I did this and then?

    <%@ WebHandler Language="VB" Class="word" %>

    Imports System

    Imports System.Web

    Public Class word : Implements IHttpHandler


    Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest

    context.Response.ContentType = "text/csv"

    context.Response.AddHeader("content-disposition", "attachment;filename=yourdoc.csv")

    context.Response.Write("Hello World!")

    End Sub


    Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable

    Get

    Return False

    End Get

    End Property

    End Class

    What should I do with it?

    thanx
    "ThatsIT.net.au" <me@work> schreef in bericht news:...
    change

    context.Response.ContentType = "application/msword"
    context.Response.AddHeader("content-disposition", attachment;filename=yourdoc.doc")

    to

    context.Response.ContentType = "text/csv"
    context.Response.AddHeader("content-disposition", attachment;filename=yourdoc.csv")





    "ton" <> wrote in message news:cb10b$4a9f93ea$541ee3e6$1.nb.home.nl...
    > no it will be a delimited file to use in a mailmerge with a standerd word
    > doc
    >
    > "ThatsIT.net.au" <me@work> schreef in bericht
    > news:...
    >> What type of file a word doc?
    >>
    >> create a ashx page (Generic handler) not a aspx page, something like this
    >>
    >>
    >>
    >> Imports System.Web
    >> Imports System.Web.Services
    >>
    >> Public Class word
    >> Implements System.Web.IHttpHandler
    >>
    >> Sub ProcessRequest(ByVal context As HttpContext) Implements
    >> IHttpHandler.ProcessRequest
    >>
    >> context.Response.ContentType = "application/msword"
    >> context.Response.AddHeader("content-disposition",
    >> "attachment;filename=yourdoc.doc")
    >> context.Response.Write("Hello World!")
    >>
    >> End Sub
    >>
    >> ReadOnly Property IsReusable() As Boolean Implements
    >> IHttpHandler.IsReusable
    >> Get
    >> Return False
    >> End Get
    >> End Property
    >>
    >> End Class
    >>
    >>
    >>
    >>
    >> "ton" <> wrote in message
    >> news:9eef7$4a9f888a$541ee3e6$1.nb.home.nl...
    >>> Hi
    >>>
    >>> In my app I create an file. I want the user to save this file on the loca
    >>> drive (c:\temp). Once saved the user can open Word and use this file as a
    >>> merge file so a letter can be generated.
    >>>
    >>> How can this be doen with ASP (vb2005) & javascript
    >>>
    >>> thanx
    >>>
    >>> ton
    >>>

    >>

    >
     
    ton, Sep 3, 2009
    #16
  17. Better to not use the Ajax.

    if you cant give a link to the file, then its not going to work no matter what.

    you simply have to allow the user to navagate to it, it does not have to be the same button

    all it needs is

    <a href="myfile.ashx">click here</a>
    "ton" <> wrote in message news:cd51f$4aa01186$541ee3e6$1.nb.home.nl...
    when adding these line in an non ajax enviroment it gives the popup dialog to open or save the file. Using it on a button within an updatepanel I get:

    sys.webforms.pagerequestmanagerparsererrorexception: the message received from the server could noy be parsed. Common causes for this error are when the rersponse is modified bij calls response.write(), response filters, httpmodules or server trace is enabled. etc

    so how about this challenge?

    I do not use the ashx file.

    any ideas?

    thanx

    ton


    "ton" <> schreef in bericht news:7638e$4a9ffb74$541ee3e6$1.nb.home.nl...
    btw it is all running in an ajax updatepanel
    have not done it, but I still do not get it where the ashx get involved. The button procedure creates the doc file on the server and then what?

    thanx
    "ThatsIT.net.au" <me@work> schreef in bericht news:...
    change path to fiole to suit

    replace previous 3 lines of code with





    context.Response.ContentType = "text/csv"

    context.Response.AddHeader("content-disposition", "attachment;filename=yourdoc.csv")

    Dim csvFile As IO.FileInfo = New IO.FileInfo(context.Server.MapPath("\yourfolder\yourfile.csv"))

    Dim sr As IO.StreamReader = csvFile .OpenText

    context.Response.Write(sr.ReadToEnd)





    "ThatsIT.net.au" <me@work> wrote in message news:...
    sorry I did not get straight back as promised I had a long phone call

    will give you the code in a minute or 2



    "ton" <> wrote in message news:251dc$4a9fca41$541ee3e6$1.nb.home.nl...
    what do you mean navigating to the ashx file. The webpage shows information about customer data, with textboxes, dropdownlist, buttons and so on. Pressing on the "sendletter button" creates a csv or text file whatever. It is this file I want to promt to the user so he can save it. After opening word and choosing the correct template this file will be used in the merge.

    Other questions are in your message

    Thanx
    "ThatsIT.net.au" <me@work> schreef in bericht news:D...
    I guess we better make sure were reading from the same page
    a few quick questions, ill be watching for your answers so we can move quick

    You already have code that creates a txt file? YES

    you have all ready saved it on the server? YES

    if so what name did you give it, did you save it as blah.csv ? YES

    try navigating to the ashx file and tell me what happens


    "ton" <> wrote in message news:f2468$4a9fb5d3$541ee3e6$1.nb.home.nl...
    I'm sorry. I do use visual studio and I have added your file. But it is a ASP appllication which after clicking by the users will end in creating the txt file. This file is forst stored on the server but then. What should I do next. I still see no place where and how to use the ashx file


    thanx
    "ThatsIT.net.au" <me@work> schreef in bericht news:...
    Are you using visual studio?

    if so add a ashx page, called generic handler in the menu


    then all you need is to add 3 lines, 5the last line will write you data. ashx page is much like a aspx page but dose not include a load of stuff needed for a web page. its used for displaying other file types such as a csv file


    context.Response.ContentType = "text/csv"

    context.Response.AddHeader("content-disposition", "attachment;filename=yourdoc.csv")

    context.Response.Write("Hello World!")




    "ton" <> wrote in message news:bf418$4a9f98f7$541ee3e6$1.nb.home.nl...
    I do not know what you mean.
    Your suggestion is that I should add a file to my solution (ashx): I did this and then?

    <%@ WebHandler Language="VB" Class="word" %>

    Imports System

    Imports System.Web

    Public Class word : Implements IHttpHandler


    Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest

    context.Response.ContentType = "text/csv"

    context.Response.AddHeader("content-disposition", "attachment;filename=yourdoc.csv")

    context.Response.Write("Hello World!")

    End Sub


    Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable

    Get

    Return False

    End Get

    End Property

    End Class

    What should I do with it?

    thanx
    "ThatsIT.net.au" <me@work> schreef in bericht news:...
    change

    context.Response.ContentType = "application/msword"
    context.Response.AddHeader("content-disposition", attachment;filename=yourdoc.doc")

    to

    context.Response.ContentType = "text/csv"
    context.Response.AddHeader("content-disposition", attachment;filename=yourdoc.csv")





    "ton" <> wrote in message news:cb10b$4a9f93ea$541ee3e6$1.nb.home.nl...
    > no it will be a delimited file to use in a mailmerge with a standerd word
    > doc
    >
    > "ThatsIT.net.au" <me@work> schreef in bericht
    > news:...
    >> What type of file a word doc?
    >>
    >> create a ashx page (Generic handler) not a aspx page, something like this
    >>
    >>
    >>
    >> Imports System.Web
    >> Imports System.Web.Services
    >>
    >> Public Class word
    >> Implements System.Web.IHttpHandler
    >>
    >> Sub ProcessRequest(ByVal context As HttpContext) Implements
    >> IHttpHandler.ProcessRequest
    >>
    >> context.Response.ContentType = "application/msword"
    >> context.Response.AddHeader("content-disposition",
    >> "attachment;filename=yourdoc.doc")
    >> context.Response.Write("Hello World!")
    >>
    >> End Sub
    >>
    >> ReadOnly Property IsReusable() As Boolean Implements
    >> IHttpHandler.IsReusable
    >> Get
    >> Return False
    >> End Get
    >> End Property
    >>
    >> End Class
    >>
    >>
    >>
    >>
    >> "ton" <> wrote in message
    >> news:9eef7$4a9f888a$541ee3e6$1.nb.home.nl...
    >>> Hi
    >>>
    >>> In my app I create an file. I want the user to save this file on the loca
    >>> drive (c:\temp). Once saved the user can open Word and use this file as a
    >>> merge file so a letter can be generated.
    >>>
    >>> How can this be doen with ASP (vb2005) & javascript
    >>>
    >>> thanx
    >>>
    >>> ton
    >>>

    >>

    >
     
    ThatsIT.net.au, Sep 4, 2009
    #17
  18. ton

    ton Guest

    I prefer to use AJAX. My interface is very rich with information about customers and so on. I had the idea that writing a letter to a contact would be easy:
    - first i thought using word on the server. this does work but is a violation with the licenseagreement and not stable since office is not a multiuser product.
    - my second thougth was juist generate the merge fields in a list, let the user open word and merge this togeter to get the letter. This is not the best solution, but fair enough
    - your suggested that I could add :
    <a href="myfile.ashx">click here</a>
    i presume myfile is the file i have created. But as you suggested a button would also do the trick: the trick is:
    context.Response.ContentType = "text/csv"

    context.Response.AddHeader("content-disposition", "attachment;filename=yourdoc.csv")

    Dim csvFile As IO.FileInfo = New IO.FileInfo(context.Server.MapPath("\yourfolder\yourfile.csv"))

    Dim sr As IO.StreamReader = csvFile .OpenText

    context.Response.Write(sr.ReadToEnd)

    So what I have in mind is the following idea

    I add a button outside the updatepanel (next to the templates the user can choose from)

    after picking 1, no postback will occur, but on the clientside I will make the button vissible. The text would be GET merge file

    I create the merge file on the server and will and with your lines.

    I hope it will work. But if you have some better ideas, i would appreciate it



    thanx



    ton



    "ton" <> wrote in message
    "ThatsIT.net.au" <me@work> schreef in bericht news:...
    Better to not use the Ajax.

    if you cant give a link to the file, then its not going to work no matter what.

    you simply have to allow the user to navagate to it, it does not have to be the same button

    all it needs is

    <a href="myfile.ashx">click here</a>
    "ton" <> wrote in message news:cd51f$4aa01186$541ee3e6$1.nb.home.nl...
    when adding these line in an non ajax enviroment it gives the popup dialog to open or save the file. Using it on a button within an updatepanel I get:

    sys.webforms.pagerequestmanagerparsererrorexception: the message received from the server could noy be parsed. Common causes for this error are when the rersponse is modified bij calls response.write(), response filters, httpmodules or server trace is enabled. etc

    so how about this challenge?

    I do not use the ashx file.

    any ideas?

    thanx

    ton


    "ton" <> schreef in bericht news:7638e$4a9ffb74$541ee3e6$1.nb.home.nl...
    btw it is all running in an ajax updatepanel
    have not done it, but I still do not get it where the ashx get involved. The button procedure creates the doc file on the server and then what?

    thanx
    "ThatsIT.net.au" <me@work> schreef in bericht news:...
    change path to fiole to suit

    replace previous 3 lines of code with





    context.Response.ContentType = "text/csv"

    context.Response.AddHeader("content-disposition", "attachment;filename=yourdoc.csv")

    Dim csvFile As IO.FileInfo = New IO.FileInfo(context.Server.MapPath("\yourfolder\yourfile.csv"))

    Dim sr As IO.StreamReader = csvFile .OpenText

    context.Response.Write(sr.ReadToEnd)





    "ThatsIT.net.au" <me@work> wrote in message news:...
    sorry I did not get straight back as promised I had a long phone call

    will give you the code in a minute or 2



    "ton" <> wrote in message news:251dc$4a9fca41$541ee3e6$1.nb.home.nl...
    what do you mean navigating to the ashx file. The webpage shows information about customer data, with textboxes, dropdownlist, buttons and so on. Pressing on the "sendletter button" creates a csv or text file whatever. It is this file I want to promt to the user so he can save it. After opening word and choosing the correct template this file will be used in the merge.

    Other questions are in your message

    Thanx
    "ThatsIT.net.au" <me@work> schreef in bericht news:D...
    I guess we better make sure were reading from the same page
    a few quick questions, ill be watching for your answers so we can move quick

    You already have code that creates a txt file? YES

    you have all ready saved it on the server? YES

    if so what name did you give it, did you save it as blah.csv ? YES

    try navigating to the ashx file and tell me what happens


    "ton" <> wrote in message news:f2468$4a9fb5d3$541ee3e6$1.nb.home.nl...
    I'm sorry. I do use visual studio and I have added your file. But it is a ASP appllication which after clicking by the users will end in creating the txt file. This file is forst stored on the server but then. What should I do next. I still see no place where and how to use the ashx file


    thanx
    "ThatsIT.net.au" <me@work> schreef in bericht news:...
    Are you using visual studio?

    if so add a ashx page, called generic handler in the menu


    then all you need is to add 3 lines, 5the last line will write you data. ashx page is much like a aspx page but dose not include a load of stuff needed for a web page. its used for displaying other file types such as a csv file


    context.Response.ContentType = "text/csv"

    context.Response.AddHeader("content-disposition", "attachment;filename=yourdoc.csv")

    context.Response.Write("Hello World!")




    "ton" <> wrote in message news:bf418$4a9f98f7$541ee3e6$1.nb.home.nl...
    I do not know what you mean.
    Your suggestion is that I should add a file to my solution (ashx): I did this and then?

    <%@ WebHandler Language="VB" Class="word" %>

    Imports System

    Imports System.Web

    Public Class word : Implements IHttpHandler


    Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest

    context.Response.ContentType = "text/csv"

    context.Response.AddHeader("content-disposition", "attachment;filename=yourdoc.csv")

    context.Response.Write("Hello World!")

    End Sub


    Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable

    Get

    Return False

    End Get

    End Property

    End Class

    What should I do with it?

    thanx
    "ThatsIT.net.au" <me@work> schreef in bericht news:...
    change

    context.Response.ContentType = "application/msword"
    context.Response.AddHeader("content-disposition", attachment;filename=yourdoc.doc")

    to

    context.Response.ContentType = "text/csv"
    context.Response.AddHeader("content-disposition", attachment;filename=yourdoc.csv")





    "ton" <> wrote in message news:cb10b$4a9f93ea$541ee3e6$1.nb.home.nl...
    > no it will be a delimited file to use in a mailmerge with a standerd word
    > doc
    >
    > "ThatsIT.net.au" <me@work> schreef in bericht
    > news:...
    >> What type of file a word doc?
    >>
    >> create a ashx page (Generic handler) not a aspx page, something like this
    >>
    >>
    >>
    >> Imports System.Web
    >> Imports System.Web.Services
    >>
    >> Public Class word
    >> Implements System.Web.IHttpHandler
    >>
    >> Sub ProcessRequest(ByVal context As HttpContext) Implements
    >> IHttpHandler.ProcessRequest
    >>
    >> context.Response.ContentType = "application/msword"
    >> context.Response.AddHeader("content-disposition",
    >> "attachment;filename=yourdoc.doc")
    >> context.Response.Write("Hello World!")
    >>
    >> End Sub
    >>
    >> ReadOnly Property IsReusable() As Boolean Implements
    >> IHttpHandler.IsReusable
    >> Get
    >> Return False
    >> End Get
    >> End Property
    >>
    >> End Class
    >>
    >>
    >>
    >>
    >> "ton" <> wrote in message
    >> news:9eef7$4a9f888a$541ee3e6$1.nb.home.nl...
    >>> Hi
    >>>
    >>> In my app I create an file. I want the user to save this file on the loca
    >>> drive (c:\temp). Once saved the user can open Word and use this file as a
    >>> merge file so a letter can be generated.
    >>>
    >>> How can this be doen with ASP (vb2005) & javascript
    >>>
    >>> thanx
    >>>
    >>> ton
    >>>

    >>

    >
     
    ton, Sep 4, 2009
    #18
  19. no myfile is the ashx file,

    The address to the csv file is in the code that goes in the ashx file, line 3 below

    but instead of creating the file in the first place why not just send emails straight from the web page?

    Or create the link as I showed to the ASHX page. put the code I supplied in it, and it will work, I tested it, it works.


    "ton" <> wrote in message news:ac501$4aa0ccf1$541ee3e6$1.nb.home.nl...
    I prefer to use AJAX. My interface is very rich with information about customers and so on. I had the idea that writing a letter to a contact would be easy:
    - first i thought using word on the server. this does work but is a violation with the licenseagreement and not stable since office is not a multiuser product.
    - my second thougth was juist generate the merge fields in a list, let the user open word and merge this togeter to get the letter. This is not the best solution, but fair enough
    - your suggested that I could add :
    <a href="myfile.ashx">click here</a>
    i presume myfile is the file i have created. But as you suggested a button would also do the trick: the trick is:


    context.Response.ContentType = "text/csv"

    context.Response.AddHeader("content-disposition", "attachment;filename=yourdoc.csv")

    Dim csvFile As IO.FileInfo = New IO.FileInfo(context.Server.MapPath("\yourfolder\yourfile.csv"))

    Dim sr As IO.StreamReader = csvFile .OpenText

    context.Response.Write(sr.ReadToEnd)

    So what I have in mind is the following idea

    I add a button outside the updatepanel (next to the templates the user can choose from)

    after picking 1, no postback will occur, but on the clientside I will make the button vissible. The text would be GET merge file

    I create the merge file on the server and will and with your lines.

    I hope it will work. But if you have some better ideas, i would appreciate it



    thanx



    ton



    "ton" <> wrote in message
    "ThatsIT.net.au" <me@work> schreef in bericht news:...
    Better to not use the Ajax.

    if you cant give a link to the file, then its not going to work no matter what.

    you simply have to allow the user to navagate to it, it does not have to be the same button

    all it needs is

    <a href="myfile.ashx">click here</a>
    "ton" <> wrote in message news:cd51f$4aa01186$541ee3e6$1.nb.home.nl...
    when adding these line in an non ajax enviroment it gives the popup dialog to open or save the file. Using it on a button within an updatepanel I get:

    sys.webforms.pagerequestmanagerparsererrorexception: the message received from the server could noy be parsed. Common causes for this error are when the rersponse is modified bij calls response.write(), response filters, httpmodules or server trace is enabled. etc

    so how about this challenge?

    I do not use the ashx file.

    any ideas?

    thanx

    ton


    "ton" <> schreef in bericht news:7638e$4a9ffb74$541ee3e6$1.nb.home.nl...
    btw it is all running in an ajax updatepanel
    have not done it, but I still do not get it where the ashx get involved. The button procedure creates the doc file on the server and then what?

    thanx
    "ThatsIT.net.au" <me@work> schreef in bericht news:...
    change path to fiole to suit

    replace previous 3 lines of code with





    context.Response.ContentType = "text/csv"

    context.Response.AddHeader("content-disposition", "attachment;filename=yourdoc.csv")

    Dim csvFile As IO.FileInfo = New IO.FileInfo(context.Server.MapPath("\yourfolder\yourfile.csv"))

    Dim sr As IO.StreamReader = csvFile .OpenText

    context.Response.Write(sr.ReadToEnd)





    "ThatsIT.net.au" <me@work> wrote in message news:...
    sorry I did not get straight back as promised I had a long phone call

    will give you the code in a minute or 2



    "ton" <> wrote in message news:251dc$4a9fca41$541ee3e6$1.nb.home.nl...
    what do you mean navigating to the ashx file. The webpage shows information about customer data, with textboxes, dropdownlist, buttons and so on. Pressing on the "sendletter button" creates a csv or text file whatever. It is this file I want to promt to the user so he can save it. After opening word and choosing the correct template this file will be used in the merge.

    Other questions are in your message

    Thanx
    "ThatsIT.net.au" <me@work> schreef in bericht news:D...
    I guess we better make sure were reading from the same page
    a few quick questions, ill be watching for your answers so we can move quick

    You already have code that creates a txt file? YES

    you have all ready saved it on the server? YES

    if so what name did you give it, did you save it as blah.csv ? YES

    try navigating to the ashx file and tell me what happens


    "ton" <> wrote in message news:f2468$4a9fb5d3$541ee3e6$1.nb.home.nl...
    I'm sorry. I do use visual studio and I have added your file. But it is a ASP appllication which after clicking by the users will end in creating the txt file. This file is forst stored on the server but then. What should I do next. I still see no place where and how to use the ashx file


    thanx
    "ThatsIT.net.au" <me@work> schreef in bericht news:...
    Are you using visual studio?

    if so add a ashx page, called generic handler in the menu


    then all you need is to add 3 lines, 5the last line will write you data. ashx page is much like a aspx page but dose not include a load of stuff needed for a web page. its used for displaying other file types such as a csv file


    context.Response.ContentType = "text/csv"

    context.Response.AddHeader("content-disposition", "attachment;filename=yourdoc.csv")

    context.Response.Write("Hello World!")




    "ton" <> wrote in message news:bf418$4a9f98f7$541ee3e6$1.nb.home.nl...
    I do not know what you mean.
    Your suggestion is that I should add a file to my solution (ashx): I did this and then?

    <%@ WebHandler Language="VB" Class="word" %>

    Imports System

    Imports System.Web

    Public Class word : Implements IHttpHandler


    Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest

    context.Response.ContentType = "text/csv"

    context.Response.AddHeader("content-disposition", "attachment;filename=yourdoc.csv")

    context.Response.Write("Hello World!")

    End Sub


    Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable

    Get

    Return False

    End Get

    End Property

    End Class

    What should I do with it?

    thanx
    "ThatsIT.net.au" <me@work> schreef in bericht news:...
    change

    context.Response.ContentType = "application/msword"
    context.Response.AddHeader("content-disposition", attachment;filename=yourdoc.doc")

    to

    context.Response.ContentType = "text/csv"
    context.Response.AddHeader("content-disposition", attachment;filename=yourdoc.csv")





    "ton" <> wrote in message news:cb10b$4a9f93ea$541ee3e6$1.nb.home.nl...
    > no it will be a delimited file to use in a mailmerge with a standerd word
    > doc
    >
    > "ThatsIT.net.au" <me@work> schreef in bericht
    > news:...
    >> What type of file a word doc?
    >>
    >> create a ashx page (Generic handler) not a aspx page, something like this
    >>
    >>
    >>
    >> Imports System.Web
    >> Imports System.Web.Services
    >>
    >> Public Class word
    >> Implements System.Web.IHttpHandler
    >>
    >> Sub ProcessRequest(ByVal context As HttpContext) Implements
    >> IHttpHandler.ProcessRequest
    >>
    >> context.Response.ContentType = "application/msword"
    >> context.Response.AddHeader("content-disposition",
    >> "attachment;filename=yourdoc.doc")
    >> context.Response.Write("Hello World!")
    >>
    >> End Sub
    >>
    >> ReadOnly Property IsReusable() As Boolean Implements
    >> IHttpHandler.IsReusable
    >> Get
    >> Return False
    >> End Get
    >> End Property
    >>
    >> End Class
    >>
    >>
    >>
    >>
    >> "ton" <> wrote in message
    >> news:9eef7$4a9f888a$541ee3e6$1.nb.home.nl...
    >>> Hi
    >>>
    >>> In my app I create an file. I want the user to save this file on the loca
    >>> drive (c:\temp). Once saved the user can open Word and use this file as a
    >>> merge file so a letter can be generated.
    >>>
    >>> How can this be doen with ASP (vb2005) & javascript
    >>>
    >>> thanx
    >>>
    >>> ton
    >>>

    >>

    >
     
    ThatsIT.net.au, Sep 4, 2009
    #19
  20. On Sep 4, 10:17 am, "ton" <> wrote:
    > I prefer to use AJAX. My interface is very rich with information about customers and so on. I had the idea that writing a letter to a contact would be easy:
    > - first i thought using word on the server. this does work but is a violation with the licenseagreement and not stable since office is not a multiuser product.
    > - my second thougth was juist generate the merge fields in a list, let the user open word and merge this togeter to get the letter. This is not the best solution, but fair enough


    I think that you have to describe your idea in more details. I don't
    get what does "merge Word file and generate letter" means. What
    letter, an email? What does Word do then there, an attachment? Can you
    send a plain-text email (no attachments) and where from the email must
    be sent, from client computer?
     
    Alexey Smirnov, Sep 4, 2009
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. BusyBoy
    Replies:
    2
    Views:
    605
    =?Utf-8?B?TGVvbiBNYXluZQ==?=
    Oct 31, 2006
  2. tiewknvc9
    Replies:
    12
    Views:
    1,295
    Chris Uppal
    Feb 19, 2007
  3. Norman Yuan
    Replies:
    0
    Views:
    515
    Norman Yuan
    Jun 20, 2008
  4. Juan T. Llibre
    Replies:
    0
    Views:
    1,203
    Juan T. Llibre
    Jun 20, 2008
  5. Steve C. Orr [MCSD, MVP, CSM, ASP Insider]

    Re: Local ASPX pages won't diaplay - IE and Firefox ask to open or save file

    Steve C. Orr [MCSD, MVP, CSM, ASP Insider], Jun 21, 2008, in forum: ASP .Net
    Replies:
    1
    Views:
    860
    Cyril Gupta
    Jun 21, 2008
Loading...

Share This Page