homepage Welcome to WebmasterWorld Guest from 54.167.96.124
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
Forum Library, Charter, Moderators: ocean10000

Microsoft IIS Web Server and ASP.NET Forum

    
ASP form collection iteration deleting spaces
defanjos




msg:4559908
 10:14 pm on Mar 30, 2013 (gmt 0)

I have this weird problem.
All the field values from a form collection iteration get the spaces deleted.
For example if a field value is "John Doe", it gets written as "JohnDoe" into the database.
Or in the case below, into a text file (used for troubleshooting purposes).

I can't figure this out.
I tried urlencoding and htmlencoding, nothing works.

Thanks in advance

troubleshooting code:
===============================================
set fs=server.createobject("Scripting.FileSystemObject")
filename=server.mappath("test.txt")
set writefile=fs.OpenTextFile(filename,2,true)

for x = 1 to Request.form.count()
writefile.writeline Request.form.item(x)
next

writefile.close
set writefile=nothing
set fs=nothing

 

defanjos




msg:4559919
 10:28 pm on Mar 30, 2013 (gmt 0)

By the way, if i use:

writefile.writeline Request.form

the form fields are correct (with spaces).
It is for sure the form collection iteration that is killing the spaces.

Kendo




msg:4559925
 11:14 pm on Mar 30, 2013 (gmt 0)

It sounds like you have a filter, possible intended to remove unwanted characters, that is removing the spaces.

Every form should use one, so there should be one there somewhere. Check the input fields and if they look something like cleanName(request("name")) then "cleanName" is the name of the function being used.

defanjos




msg:4559932
 11:47 pm on Mar 30, 2013 (gmt 0)

There are no filters, the form results arrive ok at the page.

I found a work around.
I am splitting the form results at the "&" and grabbing the results.
It works.

Still not sure why the form collection iteration was removing the spaces.

workaround:
==================================

Myarray = Split(Request.Form, "&")

For i = 0 To UBound(Myarray)

writefile.writeline Split(Myarray(i),"=", 2)(0) ' field name
writefile.writeline Split(Myarray(i),"=", 2)(1) & vbcrlf ' field value

Next

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved