Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to pass parameters with spaces to the new page?

Posted on 2009-12-21
16
Medium Priority
?
330 Views
Last Modified: 2012-05-08

I want pass,
City of Dallas  as a parameter.

http://www.myWebsite.com/NewPage?City of Dallas

I only seem to be receiving City.  How to do it right? thanks
0
Comment
Question by:goodk
  • 5
  • 3
  • 2
  • +5
16 Comments
 
LVL 9

Expert Comment

by:magicdlf
ID: 26101676
Make sure you encode the string at first.
http://www.permadi.com/tutorial/urlEncoding/

0
 
LVL 18

Expert Comment

by:bruno
ID: 26101702
spaces should be sent as "%20"


http://www.example.com/NewPage?City%20of%20Dallas


however, as mentioned above, anything passed in the url should be encoded properly.
0
 
LVL 61

Expert Comment

by:HainKurt
ID: 26101730
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Expert Comment

by:code-colors
ID: 26101748

you can simply put this inside quotes, or can use "%20" as space character as mentioned above.
so if you pass it inside an anchor tag, then

<a href="http://www.myWebsite.com/NewPage?City of Dallas">click here</a>

Try It!
0
 
LVL 15

Expert Comment

by:jorge_toriz
ID: 26101832
Use the escape javascript function

document.location = "http://www.testing.com?" + escape("City of Dallas");
0
 
LVL 8

Expert Comment

by:milindsm
ID: 26102283
Try using Server.HTMLEncode("City of Dallas")
0
 
LVL 4

Expert Comment

by:apexpert
ID: 26102627
To pass parameter with spaces is nothing special we can easily get this by:

City of Dallas
0
 
LVL 4

Expert Comment

by:apexpert
ID: 26102636
use the code i have tried this code:
0
 
LVL 4

Expert Comment

by:apexpert
ID: 26102637
0
 

Author Comment

by:goodk
ID: 26102641
reader.GetName(fcount)="City of Dallas" <-- in database
temphrefstr ="AnyTable.aspx?TableName=AceData&xFieldName=" +sValue1 + "&xFieldValue=" + HttpContext.Current.Server.HtmlEncode(reader.GetName(fcount)) + "&xFieldName1=" + sValue2 + "&xFieldValue2=" + hArray[fcount];
hrefstr = "<a href=" + temphrefstr + ">" + tmpreader + InvestmentClosedDate + "</a>";
 
I only see City instead of City of Dallas
http://localhost:58297/Prod/AnyTable.aspx?TableName=AceData&xFieldName=Job&xFieldValue=City 
 
please help! thanks
 

 
0
 
LVL 9

Expert Comment

by:magicdlf
ID: 26102648
Insert this:
temphrefstr =  Server.HTMLEncode("temphrefstr");
0
 
LVL 5

Accepted Solution

by:
code-colors earned 2000 total points
ID: 26102653
just put one single quote in the href value and try it.

Change your line to

hrefstr = "<a href='" + temphrefstr + "'>" + tmpreader + InvestmentClosedDate + "</a>";

and try it!
0
 
LVL 9

Expert Comment

by:magicdlf
ID: 26102670
Here's an update. Use this will be correctly solve your issue.
hrefstr = "<a href=" + HttpUtility.UrlEncode(temphrefstr) + ">" + tmpreader + InvestmentClosedDate + "</a>";
0
 
LVL 4

Expert Comment

by:apexpert
ID: 26102742
hi dear i have tried this code which is working for me the same thing

string strq = "City of Dallas";
        lbllink.Text = "http://www.myWebsite.com/NewPage?city=City of Dallas";
0
 
LVL 4

Expert Comment

by:apexpert
ID: 26102743
hi dear i have tried this code which is working for me the same thing

string strq = "City of Dallas";
        lbllink.Text = "<a href=\"http://www.myWebsite.com/NewPage?city=" + strq + "\">http://www.myWebsite.com/NewPage?city=City of Dallas</a>";
string strq = "City of Dallas";
        lbllink.Text = "<a href=\"http://www.myWebsite.com/NewPage?city=" + strq + "\">http://www.myWebsite.com/NewPage?city=City of Dallas</a>";

Open in new window

0
 

Author Comment

by:goodk
ID: 26109748
http://localhost:58297/Prod/AnyTable.aspx?TableName=AceData&xFieldName=Job&xFieldValue=CCncr&xFieldName1=PayedTo&xFieldValue2=ACE PBNB Account
ok, on the receiving end do i have to do anything special. or just something like this? please help! thanks

if (Request.QueryString["xFieldValue2"] != null)
  string xWhere = "Where " + xFieldName1 + "='" + xFieldValue2 + "'"
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question