I decided to think about the problem a little more and thought that an iframe might be a solution. I keep the iframe hidden until the preview button is clicked and then poof it magically appears with the rendered content inside it! Ahhh, but I still had the same problem I had earlier - getting the text from the textbox into the page. Darn it! Unfortunately there is no easy way to pass text into an iframe. Microsoft should create a new server control for ASP.NET 2.0 that renders an iframe in the browser and has a .text property !!
I decide that I like the idea of using the iframe so I make my page, preview.aspx that will serve as my page inside of the iframe. How do I pass the content into this page? How do I do it? I could use the querystring. Nah - you can’t do that - it’s just not right. You can’t pass a whole bunch of stuff like that throught the querystring. Aw hell with it - why not !?!?
So I add a literal control to the page and then in the code behind I just assign the value that was passed through the querystring to the .text property of the literal.
On the parent page I add a literal and make it not visible. Then I added code so that when the preview button is pressed the .text property of the literal on that page is set to something like “<iframe src=”preview.aspx?text=” & mycontent to display & “>” and the literal is made visible. Worked out well, though not really elegant.
I wonder if I was using Whidbey if it would throw a “shitty code exception“?