January 13, 2005

Am I a bad person for doing this?

I was just working on a page and I needed to be able to do some sort of preview of the rendered HTML entered into a textbox when the user pressed the preview button.  I really don't want to leave the page that I'm on so I thought about popping up another window.  But I was left with the problem of how to get the content from the text box into the popup page.  I could have probably written some nice little javascript that would do some cool innerHTML stuff, but I wanted something a little easier.

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 & “></iframe>” and the literal is made visible.  Worked out well, though not really elegant.

Am I a bad person for passing a bunch of text like that through the querystring?  Should I change my code to use some nifty javascript instead?

I wonder if I was using Whidbey if it would throw a “shitty code exception“?

 

 

Comments,

  • Trackbacks,
  • and Pingbacks

Comments are closed.

Shortcuts

Where is Dan?


My Blog
My Blog
Twitter
Twitter
Facebook
Facebook
LinkedIn
LinkedIn
Flickr
Flickr
YouTube
YouTube
Delicious
Delicious
Foursquare
Foursquare
Pinterest
Pinterest
GetGlue
GetGlue
Pintley
Pintley
XBOX Live
XBOX Live
Last.fm
Last.fm
Windows Live
Windows Live
Telligent.com
Telligent
Graffiti CMS on CodePlex
Graffiti CMS
Popular

Recent Posts