By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,565 Members | 1,677 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,565 IT Pros & Developers. It's quick & easy.

building url newbie question - HELP:)

P: n/a
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
Share this Question
Share on Google+
6 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a

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.