473,698 Members | 2,873 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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("t extpass")
textPassed = "<html><bod y>" & textPassed & "</body></html>"
Try
'write to file
Dim path = "c:\custom\ " & fileName
If File.Exists(pat h) Then
File.Delete(pat h)
End If
Dim fs As IO.TextWriter = File.CreateText (path)

fs.Write(textPa ssed)
fs.Close()

' Open the stream and read it back.
Dim sr As StreamReader = File.OpenText(p ath)
Do While sr.Peek() >= 0
Console.WriteLi ne(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 2210
Ok, I did a workaround, but I'm still interested if anyone knows or can
guess at what happened here.

textPassed = Request.Form("t extpass")
textPassed = "<html><bod y>" & textPassed & "</body></html>"
textPassed = textPassed.Repl ace(Chr(160), "&nbsp;")
textPassed = textPassed.Repl ace("-", "-")

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
268
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 user. I'm using Visual Studio .Net 2003 for my IDE I am familiar enough with VBA to be able to write all the code to generate the document, it is just that I'm not certain how to create the word document in memory and not have Office pop-up on the...
5
1402
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 when disabling viewstate etc I still end up with ASP.NET returning contents as set with
8
1471
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 that. I am writing a WebControl Library and I want to generate everything from there... In the Render Sub of the Control I output some HTML and there I need to reference to a file in the <img> element, is there anyway to NOT have to point to a...
2
1344
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 I want to generate some text and HTML code output using VB code and I want it to be placed in the <body> part of my somename.aspx. If I use the Response.Write() method the text is put in the beginning of the file. How can I generate text and HTML...
3
1890
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; filename=""" & NomeFile & """") Response.Flush() Response.write("<table border=""1"" .....
8
5486
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 the file is as follows: <?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="test.xsl"?> <!DOCTYPE BobActivityLog SYSTEM "test.dtd">
5
3942
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 thing is when the pdf is displayed on the fly, the whole page is a gibberish code in stead of a normal pdf file. But it displays fine if I just use a link to a file on the page. Can you tell me what's the possible reason will cause this problem?...
7
8146
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 in code that I write in the *.aspx.vb and *.ascx.vb files. Why is it no longer automatically declaring the controls? Is there a way to manually force Visual Studio 2005 to regenerate these files? Is there a setting somewhere that could have...
4
3507
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 like gibberish ("׳‘׳—׳¨ ׳�׳™׳§׳•׳� ׳”׳“׳£ ׳‘׳™׳� ׳”׳“׳₪׳™׳�") even in the source code, and only on the text he prints (I print Hebrew in the web page itself, before and after the included PHP, and...
0
8683
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9031
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8904
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7741
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, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5867
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4624
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2341
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.