As you can see, the entire body will be passed in the URL, and I am trying to replace the \n with newlines, so that the textbox has those linebreaks in it.
This is how the call is done:
Code:
javascript:popBox('SendEmail.aspx?body=Hello how are \n you!?');
The problem is, the "\n" is not being replace with a newline. Instead, I get a space.
What can I do to get the NewLines in there for the textbox?
Last edited by mendhak; Feb 1st, 2005 at 10:35 AM.
Stepping through the code shows me that the "\n" is being replaced by a space in the query string itself. So I have no access to the "\n", it doesn't exist!
Is there anything else that can be done to "denote" a newline?
I don't know why you are having a problem, I just did some testing (in vb.net) and did not have any issues, maybe your circumstance is different somehow.
webform1 (page_load)
VB Code:
Response.Redirect("webform2.aspx?body=Hello how are \n you!?")
webform2 (page_load)
VB Code:
Dim str As String = Request.QueryString("body").ToString
I think it's because you're doing Response.Redirect, and I'm passing the URL in a JavaScript popup function. There's obviously something happening at the application level, with the way JS is passing the URL perhaps.
If you open up webform1.aspx, and then type this into the browser:
Code:
javascript:document.location.href='webform2.aspx?body=Hello how are \n you!?';
you should (hopefully ) have a problem.
What some people reccommended to me was to use %0a and %0d instead, but they make things worse: They actually terminate the string.
The javascript adds the newline but there is no way to pass it through the request. That's why there was a problem, but why won't the request handle this?
I think the request object can handle is fine, I think javascript is the problem. \n in javascript denotes a new line, so what I believe is happenning is that javascript is converting the value before it even makes it to the redirection. Since on a javascript redirect you can't have a line break, I think it is parsing it out so it can handle the redirect and not crash the browser.
I think the request object can handle is fine, I think javascript is the problem. \n in javascript denotes a new line, so what I believe is happenning is that javascript is converting the value before it even makes it to the redirection. Since on a javascript redirect you can't have a line break, I think it is parsing it out so it can handle the redirect and not crash the browser.
That's what I meant.
So, your saying that the javascript just removes it instead of encoding it; since encoding it doesn't work anyway, and the browser could have an invalid request if it actually had the Cariage Return Line Feed or New Line codes. That makes since. It sucks, but it makes since.