473,396 Members | 2,010 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

ASP.net/VB.net generating gibberish in file write.

Ok, did some seriously ugly meddling with javascript so that my user
can do a level of formatting which gets shunted into a hidden input
field as raw HTML code. That code is then passed back and written
directly to a file. This works..almost.

Problems:
70% of the time, when I click the "Create" asp:button object to
activate the script, the result is an HTML file which displays
" " in place of every " " and """ in place of every
dash character. Looking at the file in notepad does not show these
mystery characters, and if I save, even without doing any editing, it
fixes the file. Obviously, the " " shows up as " " on the
screen, since the   is interpreted by the browser.
20% of the time, doing the exact same thing, only the dashes are
replaced.
10% of the time, it works perfectly, still doing the exact same thing.

I bypassed the javascript and just put the raw text of what the HTML
output should be, in a textarea. Same result, so I know it's not the
javascript.

textPassed = Request.Form("textpass")
textPassed = "<html><body>" & textPassed & "</body></html>"
Try
'write to file
Dim path = "c:\custom\" & fileName
If File.Exists(path) Then
File.Delete(path)
End If
Dim fs As IO.TextWriter = File.CreateText(path)

fs.Write(textPassed)
fs.Close()

' Open the stream and read it back.
Dim sr As StreamReader = File.OpenText(path)
Do While sr.Peek() >= 0
Console.WriteLine(sr.ReadLine())
Loop
sr.Close()

Response.Write("File Created: " & fileName)
Catch ex As Exception
Response.Write(ex.Message & "<br>" & ex.StackTrace)
End Try

Feb 22 '06 #1
1 2196
Ok, I did a workaround, but I'm still interested if anyone knows or can
guess at what happened here.

textPassed = Request.Form("textpass")
textPassed = "<html><body>" & textPassed & "</body></html>"
textPassed = textPassed.Replace(Chr(160), "&nbsp;")
textPassed = textPassed.Replace("-", "-")

That fixes this symptom, but I still dont' know what the problem is...

Feb 22 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Novice | last post by:
Hi all, I'm a novice VB.NET and VBA programmer and am wondering if there is a tutorial out there on how to create a word document based on data in a database and then return that document to a web...
5
by: WL | last post by:
Hi, I'm trying to build an .ASPX file that returns the contents of a .js file, so that I can use: <script language="JavaScript" src="/mypage.aspx" type="text/javascript"></script> Even...
8
by: Lars Netzel | last post by:
Hey! I wrote a message yersterday and got some good answers and have now managed to generate a nice image. The problem is that it's all generated in an Images.Aspx file and I don't really want...
2
by: cnickl | last post by:
I’m using the usual VisualStudio setup. That is to have a “Code Behind” (somename.aspx.vb) file with all the code and the actual HTML code somename.aspx) separate. I like this setup, but now...
3
by: daniele.balducci | last post by:
Hi All, I'm generating XLS files from ASP(.Net) code using the usual code chunks ... Response.ContentType = "application/vnd.ms-excel" Response.AppendHeader("Content-Disposition", "attachment;...
8
by: Craig | last post by:
Hi there, I'm only new to Python so please bear with me. I using ElementTree to generate an XML file that will reference a DTD and an XSL file. The header information I want at the start of...
5
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, The following code was suggested by one of the users in this newsgroup when a pdf file was requested by a user from an asp page. I used the similar code in my page and the very interesting...
7
by: Nathan Sokalski | last post by:
I am an ASP.NET developer, and Visual Studio 2005 seems to have stopped declaring the controls that I add in the *.designer.vb files, therefore forcing me to manually add them before I can use them...
4
by: ofiras | last post by:
Hi everyone, I made a web page in PHP, and included in it PHP file, which prints Hebrew text. I used the web page to include other files, but only this particular PHP file makes my Hebrew look...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.