Solved

Server.UrlEncode an XPath Value

Posted on 2011-02-15
3
778 Views
Last Modified: 2012-06-21
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?
0
Comment
Question by:thyros
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 34903172
I believe that the problem is that the XPath method returns an object, so you need to convert it to a string:

<%=Server.UrlEncode(XPath("url").ToString()) %>
0
 
LVL 19

Expert Comment

by:Amandeep Singh Bhullar
ID: 35906840
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question