Thursday, March 22, 2012

Server.HTMLEncode and the # (pound) symbol

Can someone tell me why HTMLEncode doesn't convert # to %23?

I am building a querystring and the # comes through as a #, which of
course kills the rest of the items in the querystring.

Any idea? Is there another function I can use? For now I just wrote
my own to swap out any #s.query strings should not be HTML encoded, but rather URL encoded. try

HttpUtility.UrlEncode

-- bruce (sqlwork.com)

"Chris" <cmay@.walshgroup.com> wrote in message
news:44f6e099.0407130720.5cbcd001@.posting.google.c om...
> Can someone tell me why HTMLEncode doesn't convert # to %23?
> I am building a querystring and the # comes through as a #, which of
> course kills the rest of the items in the querystring.
> Any idea? Is there another function I can use? For now I just wrote
> my own to swap out any #s.
Holy crap, I can't believe that I didn't realize what I was doing.

I knew something wasn't right... I am a disgrace :)

Thanks!

"bruce barker" <nospam_brubar@.safeco.com> wrote in message news:<#83EIDPaEHA.1152@.TK2MSFTNGP09.phx.gbl>...
> query strings should not be HTML encoded, but rather URL encoded. try
> HttpUtility.UrlEncode
> -- bruce (sqlwork.com)
>
> "Chris" <cmay@.walshgroup.com> wrote in message
> news:44f6e099.0407130720.5cbcd001@.posting.google.c om...
> > Can someone tell me why HTMLEncode doesn't convert # to %23?
> > I am building a querystring and the # comes through as a #, which of
> > course kills the rest of the items in the querystring.
> > Any idea? Is there another function I can use? For now I just wrote
> > my own to swap out any #s.

0 comments:

Post a Comment