471,616 Members | 1,338 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,616 software developers and data experts.

building url newbie question - HELP:)

Hi - can someone PLEASE tell me what's wrong with the script below. In debug
I verified that 'registrant' has a value. I can't figure our how to build the
URL & this script generates the error "operator + cannot be applied to
operands of type string & method group". MANY THANKS

<a
href='https://dev.onlineforms.phsa.ca/Ccsp/CcspConfirmRegistration.htm?Registrant='" + registrant.ToString + ">Confirm Registration</a></p>"
Jul 5 '08 #1
6 2201
On Sat, 05 Jul 2008 16:48:01 -0700, Chris D
<Ch****@discussions.microsoft.comwrote:
Hi - can someone PLEASE tell me what's wrong with the script below. In
debug
I verified that 'registrant' has a value. I can't figure our how to
build the
URL & this script generates the error "operator + cannot be applied to
operands of type string & method group". MANY THANKS
Put a pair of parens after "ToString". As in "registrant.ToString()".
Jul 6 '08 #2
Hi Peter - thanks for helping but the following :

sBody += "<a
href='https://dev.onlineforms.phsa.ca/Ccsp/CcspConfirmRegistration.htm?Registrant='" + this.registrant.ToString() + ">Confirm Registration</a></p>";

still comes back with the Url below yet Debug returns (String) 67 for
'registrant' & the project builds without error

https://dev.onlineforms.phsa.ca/Ccsp...tm?Registrant=

-----------------------------------------------------------------

"Peter Duniho" wrote:
On Sat, 05 Jul 2008 16:48:01 -0700, Chris D
<Ch****@discussions.microsoft.comwrote:
Hi - can someone PLEASE tell me what's wrong with the script below. In
debug
I verified that 'registrant' has a value. I can't figure our how to
build the
URL & this script generates the error "operator + cannot be applied to
operands of type string & method group". MANY THANKS

Put a pair of parens after "ToString". As in "registrant.ToString()".
Jul 6 '08 #3
On Sat, 05 Jul 2008 20:45:02 -0700, Chris D
<Ch****@discussions.microsoft.comwrote:
Hi Peter - thanks for helping but the following :

sBody += "<a
href='https://dev.onlineforms.phsa.ca/Ccsp/CcspConfirmRegistration.htm?Registrant='"
+ this.registrant.ToString() + ">Confirm Registration</a></p>";

still comes back with the Url below yet Debug returns (String) 67 for
'registrant' & the project builds without error
https://dev.onlineforms.phsa.ca/Ccsp...tm?Registrant=
I'm having a hard time really understanding your question. There's just
so little context and the question itself is hard to parse.

However, given that you've surrounded the text
"https://dev.onlineforms.phsa.ca/Ccsp/CcspConfirmRegistration.htm?Registrant="
with single-quotes, I'm not too surprised that that's what comes back as
the URL. The text you're trying to add to that is outside the
single-quotes and so wouldn't be considered part of the URL (you maybe
should consider yourself lucky you get any URL at all out of that :) ).

Perhaps changing the code to read:

sBody += "<a
href='https://dev.onlineforms.phsa.ca/Ccsp/CcspConfirmRegistration.htm?Registrant="
+
this.registrant.ToString() + "'>Confirm Registration</a></p>";

would work better.

Pete
Jul 6 '08 #4
Bingo!!!!! ... :-) You made my day Peter. Huge thanks ... Chris

"Peter Duniho" wrote:
On Sat, 05 Jul 2008 20:45:02 -0700, Chris D
<Ch****@discussions.microsoft.comwrote:
Hi Peter - thanks for helping but the following :

sBody += "<a
href='https://dev.onlineforms.phsa.ca/Ccsp/CcspConfirmRegistration.htm?Registrant='"
+ this.registrant.ToString() + ">Confirm Registration</a></p>";

still comes back with the Url below yet Debug returns (String) 67 for
'registrant' & the project builds without error
https://dev.onlineforms.phsa.ca/Ccsp...tm?Registrant=

I'm having a hard time really understanding your question. There's just
so little context and the question itself is hard to parse.

However, given that you've surrounded the text
"https://dev.onlineforms.phsa.ca/Ccsp/CcspConfirmRegistration.htm?Registrant="
with single-quotes, I'm not too surprised that that's what comes back as
the URL. The text you're trying to add to that is outside the
single-quotes and so wouldn't be considered part of the URL (you maybe
should consider yourself lucky you get any URL at all out of that :) ).

Perhaps changing the code to read:

sBody += "<a
href='https://dev.onlineforms.phsa.ca/Ccsp/CcspConfirmRegistration.htm?Registrant="
+
this.registrant.ToString() + "'>Confirm Registration</a></p>";

would work better.

Pete
Jul 6 '08 #5
url = string.Format("https://dev.blah.ca/blah?Registrant={0}",
HttpUtility.UrlEncode(registrant));

01: It's neater to use string.Format
02: You need to use UrlEncode.
Pete

Jul 6 '08 #6

Thanks Peter - much, much cleaner than my string:) Have a good week ... c

"Peter Morris" wrote:
url = string.Format("https://dev.blah.ca/blah?Registrant={0}",
HttpUtility.UrlEncode(registrant));

01: It's neater to use string.Format
02: You need to use UrlEncode.
Pete

Jul 7 '08 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Ye | last post: by
jeffbroodwar
reply views Thread by jeffbroodwar | last post: by
3 posts views Thread by jonathon | last post: by
1 post views Thread by ZEDKYRIE | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.