Inserting controls into blogpost

Topics: ASP.NET 2.0, Business Logic Layer, Controls
Sep 10, 2007 at 12:15 AM
Edited Sep 10, 2007 at 12:16 AM
Is there any way to insert ASP.NET controls into a blogpost?

I have a usercontrol/custom control that I want embed in a series of blogposts to demonstrate some functionality directly in the post. I know this wouldn't be supported by the RSS feed, but that is fine.

Let me suggest a type of plugin-system (similar to what Umbraco have) where I can insert a custom control that implements a certain interface (ie. RenderPage(HtmlWriter writer) and RenderFeed(HtmlWriter writer)). Controls are registered either through reflection (expensive) or in a .config file and will then be available for insertion from a dropdown in the HTML editor. Inserting a control would popup a configuration panel much like what the image button does (actually maybe the Image button should just be this type too).

Thoughts?

----------------------
Hold skruen i vand hjemme i Danmark! Der er et skide godt stykke arbejde i den her blogengine.
Sep 10, 2007 at 12:14 PM
Hi!

Take a look here: http://blog.madskristensen.dk/post/User-control-injection-in-BlogEngineNET-12.aspx

Yours,..
Nov 11, 2007 at 5:03 AM
I love this feature!

It works perfectly, except I am suffering from a bit of ignorance... How to do this:

it is suggested that you use AJAX in the form of client-callbacks instead of postbacks

My usercontrol consists of a few textboxes, a button, and some labels... and code to set the labels, i.e., a simple calculator.

Should the contents of the acsx be within an AJAX update panel, or... ?


Appreciative of any guidance,

Dan
Coordinator
Nov 11, 2007 at 7:11 PM
Not updatepanel but something else to handle an AJAX call. I would personally prefer to do it as a client-callback by implementing the ICallbackEventHandler interface on the usercontrol's code-behind class.
Nov 12, 2007 at 3:09 AM

madskristensen wrote:... by implementing the ICallbackEventHandler interface on the usercontrol's code-behind class.


After looking into this technique, I discovered:

Note that the arguments sent between the client script and the server code can only be strings


I'd be better off just using javascript in the usercontrol... and I might do just that.


Thanks!


Coordinator
Nov 12, 2007 at 7:49 PM
You can check out the /User controls/CommentView.ascx.cs file to see how the comments are added using the ICallbackEventHandler mechanism.
Nov 13, 2007 at 4:48 AM
Edited Nov 13, 2007 at 4:48 AM

madskristensen wrote:
You can check out the /User controls/CommentView.ascx.cs file to see how the comments are added using the ICallbackEventHandler mechanism.


There is more code in the eventhandler than there is in my usercontrol ::grin::

I've been meaning to convert the usercontrols to javascript anyhow, this just serves as my incentive.



Just curious though-- why won't an update panel (or update panel+scriptmanager) work?
Jan 6, 2008 at 3:29 AM
Edited Jan 6, 2008 at 3:30 AM
I got around the pesky problem of the page returning to the top after postback by adding:

  • MaintainScrollPositionOnPostBack="true"

to the post.aspx page declaration...


It's not as elegant as the ICallback_ mechanism, but it works for me.