Saurabh Tiwari
Saurabh Tiwari

Reputation: 41

encode url having Xpath in Query String

I want to send title of news to some other page through query string. My title is dynamic so it may contain '&' or other special characters. So I tried this

  <a href="NewsByTitle.aspx?title=<%#HttpServerUtility.HtmlEncode(XPath("title"))%>"

But I am getting error "The best overloaded method match for 'System.Web.HttpServerUtility.HtmlEncode(string)' has some invalid arguments" Please help me.

Upvotes: 1

Views: 449

Answers (1)

Samiey Mehdi
Samiey Mehdi

Reputation: 9424

Replace with this code:

<a href='NewsByTitle.aspx?title=<%#Server.UrlEncode( XPath("@title").ToString()) %>' ><%# XPath("@title") %></a>

Upvotes: 1

Related Questions