Link to home
Start Free TrialLog in
Avatar of thyros
thyros

asked on

Server.UrlEncode an XPath Value

I'm using an asp:XmlDataSource element with an asp:Repeater and the following XPath element works fine, but I need to know how to Server.UrlEncode the output value:

<%#XPath("title") %>

Open in new window


For example if the value was 'Sony T100 Digital Camera'  I want to build an output url like this:

<a href="http://www.example.com/-Sony+T100+Digital+Camera">Sony T100 Digital Camera</a>

When I tried to use something like the following, it gives a server exception error:

<a href="http://www.example.com/-<%=Server.UrlEncode(XPath("url")) %>"><%#XPath("title") %></a>

Open in new window


Compiler Error Message: CS1502: The best overloaded method match for 'System.Web.HttpServerUtility.UrlEncode(string)' has some invalid arguments

Using inline code, how can I get the XPath value of 'title' to be url encoded?
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.