I have a pretty long string. Before I databind the string, I want to be able to modify the string by inserting some more text. For example, I have a string <a href="/a/info/a.html"><img src="/userimage/imgs.jpg"/></a> I need to insert http://m.mydom.com right before the /a and right before /userimage. Note, this will always be the same so it is safe to say that the string I want to add to will be consistent. I would like to do this either with lamda or just c#. Thanks for any help.
I have a pretty long string. Before I databind the string, I want to
Share
If you need to do this for all relative paths on your page, using C# to accomplish this is actually not the best tool for this.
HTML comes with an element called
base(see spec information) that is used to specify a document’s base URI explicitly. If you changed your HTML to something like the following:Both the image and the anchor will point to the correct base. Don’t believe me? Check out this jsFiddle demonstating the amazingness of
base.