Here’s the situation: A user clicks a button on a webpage and an iframe pops up (facebox which similar to lightbox). Now I want to inject some html from the asp.net code behind of the iframe into the parent window. I’m using JQuery to achieve this and this simple line of code does the trick:
That works fine except when you’re trying to insert a string which contains line breaks. I’m not talking about html line breaks here but windows line breaks as in new line and carriage return (\n\r). The problem is that because the string will span on several lines, the expression will be unterminated. Have a look at the following to understand what I’m trying to say more clearly:
how are you?
how are you?);
To make this work, you need to remove the line breaks as follows:
string myContent = "hello world\n\rhow are you?"; myContent.Replace("\n", "").Replace("\r", "");