Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
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
  #1 (permalink)  
Old August 17th, 2006, 04:39 PM
Authorized User
 
Join Date: Jun 2006
Location: , , .
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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

  #2 (permalink)  
Old August 17th, 2006, 11:28 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

;;;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
  #3 (permalink)  
Old August 18th, 2006, 12:10 PM
Authorized User
 
Join Date: Jun 2006
Location: , , .
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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>

  #4 (permalink)  
Old August 18th, 2006, 01:05 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

<%=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."
  #5 (permalink)  
Old August 18th, 2006, 01:14 PM
Authorized User
 
Join Date: Jun 2006
Location: , , .
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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>

  #6 (permalink)  
Old August 18th, 2006, 01:26 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

<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."
  #7 (permalink)  
Old December 13th, 2006, 05:52 PM
Registered User
 
Join Date: Dec 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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>


  #8 (permalink)  
Old December 13th, 2006, 06:05 PM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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 &nbsp; to cause a "non breaking space".

The following in your HTML source

"a&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;buncho fspaces"

will end up as

"a bunchofspaces"

in the browser.

Cheers,

Imar


  #9 (permalink)  
Old December 13th, 2006, 06:14 PM
Registered User
 
Join Date: Dec 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Man .... that was quick. Thanks!

I guess I should review my html before diving into asp

Thanks again,
Matt

  #10 (permalink)  
Old December 13th, 2006, 06:34 PM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

You're welcome....

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.


Similar Threads
Thread Thread Starter Forum Replies Last Post
Store ? in Oracle9i using asp.net web form nandini_net_in ASP.NET 2.0 Professional 0 October 17th, 2006 12:42 AM
Problem with Posting an ASP .Net web form eliea ASP.NET 1.0 and 1.1 Basics 4 September 11th, 2006 02:59 AM
Unexpected Form Behavior SerranoG Access VBA 2 December 16th, 2004 05:50 PM
unexpected behavior from microsoft web page ronaldo11 C# 0 July 6th, 2003 09:33 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.