I am suing iframe control in the edit mode.
I need to preserve white space in the control.
e.g. if I put following data in the control and then save in the database,
SSDB.CLMP1SO 735837 735837 0 0
SSDB.CNCP2SO 735837 735837 0 0
SSDB.CYMP3SO 735837 735837 0 0
SSDB.CYMP4SO 735837 735837 0 0
SSDB.RCPP1SO 735837 735837 0 0and reload in the iframe control, the extra white space between the word is removed.
I tried style="white-space:pre" but that does not seem to work.
I do not want to use <pre></pre>, as I am doing some active formatting in the control.
As suggested in the article:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnie60/html/cssenhancements.asp
Even after turning the <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> standard compliant mode on, iframe element does not seem to support white-space:pre style.
Please suggest.
Thanks,
Paresh
![]() |
0 |
![]() |
for an interesting read on PRE, i'd recommend this article: http://cheeaun.phoenity.com/weblog/2005/06/whitespace-and-generated-content.html
Mike Banavige
~~~~~~~~~~~~
Need a site code sample in a different language? Try converting it with: http://converter.telerik.com/
![]() |
0 |
![]() |
Very good read indeed - thanks. Since the trials there are not applicable to internet explorer at all, I will not be able to use them.
I know that preserving white space in the iframe control is possible in internet explorer.
I am using innovaEditor which supports that - I don't know how they achieve it. (It does not seem to be style sheet)
I need to be able to do that in my own application.
Any suggestions?
Thx,
Paresh
![]() |
0 |
![]() |
if the whitespace is preserved without pre or a css style, then i would suspect it is being entered as nonbreaking space entities
i.e.
or
chr(160)
just a guess though...
Mike Banavige
~~~~~~~~~~~~
Need a site code sample in a different language? Try converting it with: http://converter.telerik.com/
![]() |
0 |
![]() |
Actually my problem is - I want to preserve it.
It is not being preserved. (I know they are stored OK in the database as if I reload it in a normal textarea they are shown)
However, if I reload it in an iframe - they are lost.
Paresh
![]() |
0 |
![]() |
correct. when you dont use a pre tag and you havent applied some form of css to prevent it, the browser will collapse repeating whitespace characters into a single whitespace character. this is how the browser renders spaces.
to not use css and to not use a pre tag, you would need to replace the whitespace chars with " " for display purposes only.
i.e. when assigning the db value to a label you could try something like:
Label1.Text = myDbValue.Replace(" ", " ")But when assigning that same value to a multiline textbox, you would not alter it
TextBox1.Text = myDbValueThis same technique is also used for CRLF's entered in a multiline textbox.
Label1.Text = myDbValue.Replace(Environment.Newline, "<br />")
Mike Banavige
~~~~~~~~~~~~
Need a site code sample in a different language? Try converting it with: http://converter.telerik.com/
![]() |
0 |
![]() |
Mike,
Thanks for this suggestion, I will try replaced space with as you suggested.
Here is how I defined my iframe control with CSS to instruct it to preserve white space. But that does not seem to work.
<iframe id="xyz" style="white-space:pre">
</iframe>
I was hoping that would work.
Thx,
Paresh.
Paresh
![]() |
0 |
![]() |
i do not believe that the css style of an iframe actually affects the content of the document that is contained inside the iframe. I suspect this is why your style did not have the desired affect.
Perhaps you can do the replacement or perhaps you can get the white-space:pre into the content you reference in the iframe.
Mike Banavige
~~~~~~~~~~~~
Need a site code sample in a different language? Try converting it with: http://converter.telerik.com/
![]() |
0 |
![]() |
Mike,
Thanks a bunch.
Using solved the issue in the applications which I designed in house.
However, I need to do the same thing in one of our third party applications too and there if I replace space with " " it shows up as it is with "&" replaced with some other character.
SSDB.CNCP2SO ;�nbsp;�nbsp;�nbsp;�nbsp;�nbsp;�nbsp;�nbsp;�nbsp;�nbsp;�nbsp;�nbsp;�nbsp;�nbsp;735837�nbsp;
So, I tried replacing it with "&nbsp" - but still no use, I am getting this.
SSDB.RCPP2SO&;nbsp;�amp;nbsp;�amp;nbsp;�amp;nbsp;�amp;nbsp;�amp;nbsp;�amp;nbsp;�amp;nbsp;�amp;nbsp;�amp;nbsp;�amp;nbsp;�amp;nbsp;�amp;nbsp;�amp;nbsp;735837�amp
Any idea what might be happening here?
I am using javascript to replace "space" with " " - like this.
document.frmNotes.txaWorkNote.value = document.frmNotes.txaWorkNote.value.replace(/ /gi," ");
I guess their might be some settings in the control of the third party application which does that - but not able to determine what.
Any suggestions?
Thx,
Paresh.
Paresh
![]() |
0 |
![]() |
I think I know the reason for the above issue.
1. If I replace space using vbscript directly on the database output like replace(fieldname, " ", " ") - everything works fine.
2. However if I use javascript to do the same using document.frmNotes.txaWorkNote.value.replace(/ /gi," "), it results in above mess.
In the application where I need to use javascript, I need to fixe this.
Can't seem to find a logical reason for the difference though.
Any suggestions?
Thx,
Paresh.
Paresh
![]() |
0 |
![]() |
I guess the much cleaner solution can be: to specify <style> body {white-space:pre} </style> for the document.
And then to make the browser compliant by specifying:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
Unfortunately that does not change iframe content behavior.
If iframe content is defined dynamically - is there any way to specify !DOCTYPE for the iframe element in IE?
Thanks,
Paresh.
Paresh
![]() |
0 |
![]() |
Mike,
Thanks - that was useful. Looks like I need to replace space with " " to achieve the behavior I am looking for.
However I have an issue:
Suppose the data is "xx yy zz"
At some points in my application I can do it while loading my data back from the database on the server side.
(First it gets loaded into a textarea and then to an iframe down the line)
e.g. replace(columnname, " ", " ") - which works fine - no issues.
I see "xx yy zz" in the textarea and same thing correctly in the iframe at the later stage.
However at other places I need to use Javascript as data loaded to iframe comes from the textarea without any trip to the database.
However, if I use javascript to replace white space: like myText.replace(/ /gi, " ")
The textarea gets populated with "xx yy zz"
I guess " " is taken as string.
How do I achieve same behavor as server side replacement of space with " " using javascript?
Any ideas?
Thanks,
Paresh.
Paresh
![]() |
0 |
![]() |