Rendering ASP.NET controls inside blog posts

Topics: ASP.NET 2.0, Controls
Jul 27, 2007 at 8:56 AM
Hello everyone,

I am looking for help with following issue. I need to render ASP.NET web server controls inside of blog posts mainly in relation with Silverlight items. I want to use both ASP.NET futures Silverlight Media Control and Telerik RAD Controls for Silverlight to post various videos and animations as parts of blog posts. If I am correct in my understanding, as of now BlogEngine.NET simply passes the content of blog posts as simple text into final page. How to make it a part of ASP.NET rendering pipeline? For me this is crucial issue. I love BlogEngine.NET and prefer it to other engines but without some progress on this field, I am in dead end. Any advice whatsoever will be appreciated.

Jan Sichula
(Slovak Republic)

Jul 27, 2007 at 9:11 PM
Could you use something like Windows Live Writer and use a plugin for media?


JanSichulaJr wrote:
Hello everyone,

I am looking for help with following issue. I need to render ASP.NET web server controls inside of blog posts mainly in relation with Silverlight items. I want to use both ASP.NET futures Silverlight Media Control and Telerik RAD Controls for Silverlight to post various videos and animations as parts of blog posts. If I am correct in my understanding, as of now BlogEngine.NET simply passes the content of blog posts as simple text into final page. How to make it a part of ASP.NET rendering pipeline? For me this is crucial issue. I love BlogEngine.NET and prefer it to other engines but without some progress on this field, I am in dead end. Any advice whatsoever will be appreciated.

Jan Sichula
(Slovak Republic)



Jul 27, 2007 at 9:59 PM
As I understand, this is not a possiblity, given the current nature of blog engine. Blog engine will grab the blog content as text and throw it onto a page, long after all the .net components hvae already been handled. The only way to do what you are looking for (that I have experience with) is to use virtual path providers to deliever the xml content as page content before the .net code is fired. This would require ALOT of rewrite on the BlogEngine.net code. In other words, I don't think it a plausible task.

Of course, there are probably ways around it, which are not much better. You could write a page that will take a request and load teh proper silverlight control and embed it. Then, you can add a iframe in your post. Kindof messy, but should work. There are probably other "work arounds" like that as well.

Hope this helps.
Jul 29, 2007 at 11:02 PM
I'm no BE.net expert but after a quick sniff around the sourcecode I thought this is something that could quite easily be added at the theme level so as not to disturb the core code and would probably be more easy to keep going as new releases appear assuming the functionality is not built-in :) :)

Anyway....

Have a look @

\themes\standard\PostView.ascx

You'll notice that theres a 'Inherits="BlogEngine.Core.Web.Controls.PostViewBase"' at the top of the control which is where the code is to actually drag through content etc

What we need to do is change the Inherits directive so it looks at a newly created code-behind page and then Inherit the 'PostViewBase' class on this. This way we now have somewhere to catch the content in code before it hits the main control. Then its a case deciding just how you want to manage things. From similar projects I've used tages like ::MyCustomControl::Param1::Param2:: in the content which is then rendered by loading 'MyCustomControl.ascx' from a parametrised location using the .LoadControl and .AddControl methods as its processed.

Devs, if you are reading this. Is this something you would consider adding into the main sourcecode if I implemented it ?

Hope it makes sense. t I'll put something together for you to have a look just to make sure I am not talking a load of nonsense which I have been known to do :)
Jul 30, 2007 at 9:32 AM
Hello everyone,

message for BlogEngine.NET developers: I am deeply convinced that ability to render ASP.NET controls inside blog posts is an absolute must have. Please, please, put it on a high priority and make it standard part of BlogEngine.NET.

Message for sfxpete: Your advice sounds exciting but I am still more of a learner with ASP.NET programming. Would you please provide me with actual modified files? This way I will be able to implement it. Thank you in advance for your kindness.

Jan Sichula
(Slovak Republic)
Jul 30, 2007 at 11:42 AM
Sure, I'll implement the change as its something I'd like myself as well.

Can I just add that the BE.net code is VERY well written and is making what I'm intending to do soooo much easier to implement, hats off to the developers!!!!!
Jul 31, 2007 at 12:06 AM
Edited Jul 31, 2007 at 12:17 AM
Right then. As promised. I just tested this out things work OK with it. Its nothing more then a tech demo to show that this is possible without to much heartache. As already stated I've choose to make the changes at theme level as this way will probably be easier to keep going. Onto the changes!

I've had to host the instructions on a server as the formatting was messed up in here...

User Control Instructions - http://www.r720.co.uk/projects/usercontrol.txt

The code works simply by looking for posts that start ':::::' then assumes the rest of the post is the user controls path for it to locate. Its far from perfect and serves only as a demo. I'm considering going ahead and intergrating it into the core project whilst adding some friendly features into the admin panel to make it a snap to use.

Will many peeps find this useful?
Jul 31, 2007 at 6:48 PM
Hello sfxpete,

I have meticulously followed your instructions and it works. Even RadControls for Silverlight by Telerik render correctly. Thank you very much for your kind help.

Jan Sichula
(Slovak Republic)
Jul 31, 2007 at 8:19 PM
No problem at all!!! I've just got of the latest source code which is what v1.2 will be. There is a new extensions model which makes it really easy to hook into key events in the blog and do this more cleanly. I'm producing an extension which I hope will be included in the final release and be of some use to us all. I'm also working on using this functionality to build the much requested picture gallery functionality :)