|
Subject:
|
do not understand asp web form behavior
|
|
Posted By:
|
dhx10000
|
Post Date:
|
8/17/2006 4:39:06 PM
|
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
|
|
Reply By:
|
mat41
|
Reply Date:
|
8/17/2006 11:28:20 PM
|
;;;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
|
|
Reply By:
|
dhx10000
|
Reply Date:
|
8/18/2006 12:10:49 PM
|
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>
|
|
Reply By:
|
dparsons
|
Reply Date:
|
8/18/2006 1:05:11 PM
|
<%=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."
|
|
Reply By:
|
dhx10000
|
Reply Date:
|
8/18/2006 1:14:35 PM
|
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>
|
|
Reply By:
|
dparsons
|
Reply Date:
|
8/18/2006 1:26:40 PM
|
<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."
|
|
Reply By:
|
swizelfritzer
|
Reply Date:
|
12/13/2006 4:52:15 PM
|
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>
|
|
Reply By:
|
Imar
|
Reply Date:
|
12/13/2006 5:05:59 PM
|
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 bunchofspaces"
will end up as
"a bunchofspaces"
in the browser.
Cheers,
Imar
|
|
Reply By:
|
swizelfritzer
|
Reply Date:
|
12/13/2006 5:14:49 PM
|
Man .... that was quick. Thanks!
I guess I should review my html before diving into asp
Thanks again, Matt
|
|
Reply By:
|
Imar
|
Reply Date:
|
12/13/2006 5:34:15 PM
|
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.
|