Archive

Archive for August, 2006

Rendering the HTML Output of a Server Control

August 17th, 2006 Michael Bell No comments

I recently found a neat trick to render the output of a control without actually having to add the control itself to a page or control. I found this very handy when trying to use a site template that everything must fit in, and the controls may have various locations within the page that they need rendered. In my case, I had HTML graphics comps that had specific spots in it that I would need to place specific controls. The graphics comps could be swapped out on the fly, and the controls would need to be rendered in different places based on which graphics comp was used. See what I did here to render the control HTML within the “CONTENTHERE” placeholder of the graphics design comp HTML.

ThemeObject to = bl.getTheme(siteID);

StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
HtmlTextWriter tw = new HtmlTextWriter(sw);

GalleryControl gallery = new GalleryControl();
gallery.ID = “gallery”;    
gallery.RenderControl(tw);
sHTML = sb.ToString();
sHTML = to.Body.Replace(“CONTENTHERE”, sHTML);

Categories: ASP.NET, c# Tags:

mod_rewrite – HttpContext.Current.RewritePath vs HttpContext.Current.Server.Transfer

August 17th, 2006 Michael Bell No comments

So I’m trying to hide the “real” url of the page being executed in my web app via an HttpModule. I found out today that if you use Server.Transfer, the page you transfer TO has a problem with postbacks that will take us to the “hidden” URL after a submit (button click or whatever). After tinkering with my buttons for about 4 hours trying to get them to submit different, I finally replaced my Server.Transfer with HttpContext.Current.RewritePath where I’m catching the request (OnBeginRequest) in my HttpModule. Once I did that, the browser was brought back to the “hidden” URL after postback. 4 hour painful lesson learned and now shared :)

Categories: ASP.NET, c# Tags:

Finally have my own BLOG up!

August 17th, 2006 Michael Bell No comments

Only took a few years… but finally here. So I will post both code and daily life ramblings here :)

Categories: Whatever Tags: