Search code examples
asp.netcomponentart

Building Server Controls like ComponentOne or ComponentArt lirbaries


I'm an expert web developer knowing all famous web frameworks.

I want to build a collection of Server Controls like ComponentArt components that you can use in your projects.

In ComponentArt: You can easily register the namespace of componentart in your project and bind data to those controls without any additional code or effort (like copying any additional files to our sample projects) and ofcourse they support ajax.

To accomplish this I came to realize that I have to develop some advanced UserControls that support callbacks for handling ajax and there are not much of a information about sharing UserControls amongst different projects. Actually here is the only useful link: http://www.codeproject.com/KB/user-controls/EmbeddedUserControl.aspx

On the other hand Server Controls don't have ascx template interfaces that I can comfortably design my control layouts.

I need a way to develop some web components that you can:

  1. Share amongst other projects easily (Just add dll to project and start using it)
  2. Support CallBack For ajax(for example ICallbackEventHandler)
  3. Can have a Template for HTML Design (like UserControl that have ascx template file) so you don't have to hardcode HTML in your code like:

    output.Write("<table>content</table>");

Custom Server Controls have the first two, but they don't have ascx files so you have to write all of your html code inside your cs file

Please advise...


Solution

  • Instead of hard coding your HTML you could have your Server Controls read it from a file, whose name and path you determine based on a configuration setting or the directory path. That would allow your Server Controls to be more dynamic and not have a need for recompiling upon changing the HTML. That would help fulfill condition #3 at a slight cost to #1 (since your Server Control now relies on an outside resource it's not as easily distributable). You could always hard code the default markup and fall back to it if the file is not found as an extra precaution against exceptions.