1

I am trying to replace all the spaces in my title to use as an ID, but I keep getting this error: error CS0103: The name 'Replace' does not exist in the current context

The code I am using is this: id="<%# Eval(Replace("Title"," ", "")) %>

id="<%# Eval("Title") %> works like a dream, and I have tried various ways to get the spaces removed, like Trim and Replace, but each gives me the above error.

can you help me format the right eval please? I am using SharePoint 2010 Enterprise edition.

Thanks Louise

2
  • It seems like such a silly thing - but any .replace / .trims dont have definitions? May 7, 2012 at 13:00
  • id="<%# Eval("Title").Replace(" ", "") %>" brings back :error CS0117: 'object' does not contain a definition for 'Replace' May 7, 2012 at 13:03

2 Answers 2

2

My colleague gave me this ; id="<%# Eval("Title").ToString().Replace(" ", "") %>" and it worked! - Thanks for the help Christian!

0

could jQuery be an option for you? I think you can do this with an string replace function.

1
  • A friend suggested: String.Replace(Eval("Title"), " ", "") but I got this: error CS1501: No overload for method 'Replace' takes '3' arguments . Jquery is an option for me :) May 7, 2012 at 12:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.