 |
| Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

August 17th, 2006, 04:39 PM
|
|
Authorized User
|
|
Join Date: Jun 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
do not understand asp web form behavior
Hi everyone,
I have created a simple web form that passes parameters, via a variable, to a second action page.
The first page, I noticed, I had to write the <form> tag as follows:
<form action="actionPage.asp">
with no 'method' that I am used to writing (method=post).
The problem I am having, which may or may not have to do with the <form> tag is that some of the values of my variables that I am passing to the secondary 'action' page, contain spaces, which are getting truncated. I also noticed that my variables are being passed via the URL string. How can I get this behavior to work like a regular web form, where the values of my variables are not truncated and the values are not passed via the url string?
Here is how I am accepting the variable on the 'action' page
<%=request.queryString("myVar")
example, one of the values of the variable is "Power Management" but it appears as "Power" when I output the variable on the 'action' page.
Thanks,
SR
|
|

August 17th, 2006, 11:28 PM
|
|
Friend of Wrox
|
|
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
|
|
;;;I had to write the <form> tag as follows
Why do you have to?
;;;How can I get this behavior to work like a regular web form
Place the method="post" in your form tag to post these values using the form method.
;;;...which are getting truncated
write these variables sourounded in single and double quotes should fix the 'truncation' issue. EG:
response.write "My name is '" & trim(request.queryString("myVar")) & "'
Wind is your friend
Matt
|
|

August 18th, 2006, 12:10 PM
|
|
Authorized User
|
|
Join Date: Jun 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks for the reply, but I guess I'm not quite getting the syntax correctly in my specific situation, in regards to preventing the 'truncation' of my variables.
Here is how I am currently displaying the variable and I'm not sure how I would wrap them in the single and double quotes as you mentioned:
componentName = Request.QueryString("component")
<br><br>Component: <%=Replace(componentName,","," OR ")%></span><Br>
|
|

August 18th, 2006, 01:05 PM
|
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
<%=Replace(componentName,","," OR ")%></
The way that reads above is that you are trying to replace an , with OR as opposed to trying to remove whitespace.
Try something like this:
componentName = trim(Request.QueryString("component"))
also, if this is getting passed be the querystring (in the URL) the space wont exist anyway, the whitespace will be represented by %20 so it would look something like this:
www.mysite.com?component=power%20management
In which case your replace statement should be something like this:
<%=Replace(componentName,"%20","OR")%>
HTH.
"The one language all programmers understand is profanity."
|
|

August 18th, 2006, 01:14 PM
|
|
Authorized User
|
|
Join Date: Jun 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Sorry, there is a misunderstanding. I do NOT want the spaces to be removed, I want them preserved. That 'replace' you see is for something else I am doing. So to keep it simple this is what is happening:
This variable:
componentName = request.QueryString("component")
is displaying like this "SW-Power"
It is supposed to read like this: "SW-Power Management". So that is why I do NOT want it to be truncated. Another user suggested that I surround the variable in single and double quotes but I don't understand, in regards to syntax, how to do it if my variable is within html like this:
componentName = Request.QueryString("component")
<br><br>Component: <%=componentName%></span><Br>
|
|

August 18th, 2006, 01:26 PM
|
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
<form action="actionPage.asp" method="post">
<input type="hidden" name="component" value='<%=componentName%'>
<br><br>Component: <%=componentName%></span><Br>
</form>
actionPage.asp:
Dim sComponent
sComponent = Request.Form("component")
that should work for you.
"The one language all programmers understand is profanity."
|
|

December 13th, 2006, 05:52 PM
|
|
Registered User
|
|
Join Date: Dec 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I am sorry but I still don't understand this. I guess my question is how do I get the asp page output to read "a bunchofspaces" instead of "a bunchofspaces"
I am brand new to all of this. I hope I do not have to read into array char by char.
Thanks,
Matt
My code is below:
(Attempted something with 'REPLACE' function
<html>
<body>
<form action="reqquery.asp" method="get">
Your name: <input type="text" name="fname" size="20" />
<input type="submit" value="Submit" />
</form>
<%
dim fname
fname=Request.QueryString("fname")
If fname <> "" Then
Response.Write("Hello " & REPLACE(fname, "+", " ") & "!<br />")
Response.Write("How are you today?")
End If
%>
</body>
</html>
|
|

December 13th, 2006, 06:05 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Are you talking about the behavior where multiple spaces are replaced by a single one? If so, this is by design in HTML.
You can use to cause a "non breaking space".
The following in your HTML source
"a buncho fspaces"
will end up as
"a bunchofspaces"
in the browser.
Cheers,
Imar
|
|

December 13th, 2006, 06:14 PM
|
|
Registered User
|
|
Join Date: Dec 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Man .... that was quick. Thanks!
I guess I should review my html before diving into asp
Thanks again,
Matt
|
|
 |