By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,813 Members | 1,257 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,813 IT Pros & Developers. It's quick & easy.

save text from text box into text file

P: n/a
Hi..

I'm trying to save query path which is in text box to text file. Below
is the coding that i'm using currently:

Private Sub SaveQueryPath()
'save to text file
Response.Clear()
Response.Buffer = True
Response.AddHeader("content-disposition",
"attachment;filename=Query1.txt")
Response.ContentType = "application/vnd.text"
Response.Charset = ""
Response.Cache.SetCacheability(HttpCacheability.No Cache)
Me.EnableViewState = False

Dim oStringWriter As System.IO.StringWriter = New
System.IO.StringWriter
Dim oHtmlTextWriter As System.Web.UI.HtmlTextWriter = New
System.Web.UI.HtmlTextWriter(oStringWriter)

Me.ClearControls(txtPath)
txtPath.RenderControl(oHtmlTextWriter)

Response.Write(oStringWriter.ToString())
Response.End()
End Sub

The 'txtPath' is the text box that contains a query path that I want
to save.

However, when i open the text file, after i run and save the query,
the result in the text file shows the query path (which i need)
including the properties of the text box which is unnecessary for me.
For example(text saved):

<input name="txtPath" type="text" value=" STP --Select One-- >
" id="txtPath" disabled="disabled" style="background-
color:WhiteSmoke;font-family:Verdana;font-size:X-Small;width:712px;" /
>
The only thing that i want to save is (the query path): value=" STP
--Select One-- "
Is there anybody can help me on how to get rid of all the other
unnecessary info saved in the text file?

Hope to hear from you guys... Your help is highly appreciated.

Thank you.

Feb 8 '07
Share this Question
Share on Google+
2 Replies


P: n/a
Hi,

Why do you not use the streamwriter, a very nice exsample is on this page.

http://msdn2.microsoft.com/en-us/lib...3w(VS.80).aspx

Cor

<nu******@yahoo.comschreef in bericht
news:11**********************@v33g2000cwv.googlegr oups.com...
Hi..

I'm trying to save query path which is in text box to text file. Below
is the coding that i'm using currently:

Private Sub SaveQueryPath()
'save to text file
Response.Clear()
Response.Buffer = True
Response.AddHeader("content-disposition",
"attachment;filename=Query1.txt")
Response.ContentType = "application/vnd.text"
Response.Charset = ""
Response.Cache.SetCacheability(HttpCacheability.No Cache)
Me.EnableViewState = False

Dim oStringWriter As System.IO.StringWriter = New
System.IO.StringWriter
Dim oHtmlTextWriter As System.Web.UI.HtmlTextWriter = New
System.Web.UI.HtmlTextWriter(oStringWriter)

Me.ClearControls(txtPath)
txtPath.RenderControl(oHtmlTextWriter)

Response.Write(oStringWriter.ToString())
Response.End()
End Sub

The 'txtPath' is the text box that contains a query path that I want
to save.

However, when i open the text file, after i run and save the query,
the result in the text file shows the query path (which i need)
including the properties of the text box which is unnecessary for me.
For example(text saved):

<input name="txtPath" type="text" value=" STP --Select One-- >
" id="txtPath" disabled="disabled" style="background-
color:WhiteSmoke;font-family:Verdana;font-size:X-Small;width:712px;" /
>>

The only thing that i want to save is (the query path): value=" STP
>--Select One-- "
Is there anybody can help me on how to get rid of all the other
unnecessary info saved in the text file?

Hope to hear from you guys... Your help is highly appreciated.

Thank you.

Feb 8 '07

P: n/a
On Feb 8, 1:38 pm, "Cor Ligthert [MVP]" <notmyfirstn...@planet.nl>
wrote:
Hi,

Why do you not use the streamwriter, a very nice exsample is on this page.

http://msdn2.microsoft.com/en-us/lib...3w(VS.80).aspx

Cor

<nuhur...@yahoo.comschreef in berichtnews:11**********************@v33g2000cwv.g ooglegroups.com...
Hi..
I'm trying to save query path which is in text box to text file. Below
is the coding that i'm using currently:
Private Sub SaveQueryPath()
'save to text file
Response.Clear()
Response.Buffer = True
Response.AddHeader("content-disposition",
"attachment;filename=Query1.txt")
Response.ContentType = "application/vnd.text"
Response.Charset = ""
Response.Cache.SetCacheability(HttpCacheability.No Cache)
Me.EnableViewState = False
Dim oStringWriter As System.IO.StringWriter = New
System.IO.StringWriter
Dim oHtmlTextWriter As System.Web.UI.HtmlTextWriter = New
System.Web.UI.HtmlTextWriter(oStringWriter)
Me.ClearControls(txtPath)
txtPath.RenderControl(oHtmlTextWriter)
Response.Write(oStringWriter.ToString())
Response.End()
End Sub
The 'txtPath' is the text box that contains a query path that I want
to save.
However, when i open the text file, after i run and save the query,
the result in the text file shows the query path (which i need)
including the properties of the text box which is unnecessary for me.
For example(text saved):
<input name="txtPath" type="text" value=" STP --Select One-- >
" id="txtPath" disabled="disabled" style="background-
color:WhiteSmoke;font-family:Verdana;font-size:X-Small;width:712px;" /
The only thing that i want to save is (the query path): value=" STP
--Select One-- "
Is there anybody can help me on how to get rid of all the other
unnecessary info saved in the text file?
Hope to hear from you guys... Your help is highly appreciated.
Thank you.- Hide quoted text -

- Show quoted text -
Hi Cor,

What i'm trying to do is actually for 'Export to Text File' button.
The code behind the button is where it calls SaveQueryPath() function,
which i've posted earlier. Do you have any examples or suggestions to
solve it?

Thank you.

Feb 8 '07

This discussion thread is closed

Replies have been disabled for this discussion.