Tom Hamming
Tom Hamming

Reputation: 10981

Escaping ampersands in urls in ASP.NET

I'm building an ASP.NET 2.0 application that involves a lot of urls with several parameters. For example:

http://www.myapp.com/default.aspx?param1=val&param2=val2

I know that a link to that page should look like this in the HTML, with the ampersands escaped:

<a href='http://www.myapp.com/default.aspx?param1=val&amp;param2=val2>Text</a>

So when I'm generating HTML manually for a Literal control, I need to escape my ampersands. But do I need to do the same thing when assigning to the NavigateUrl (MSDN) property of a HyperLink, or is that done for me automatically? In general, where is this taken care of automatically in ASP.NET?

Upvotes: 0

Views: 393

Answers (1)

SLaks
SLaks

Reputation: 888167

All ASP.Net server-side controls encode user-supplied values in the HTML they generate, except where noted otherwise in the documentation.

Upvotes: 1

Related Questions