StrataFrame Forum

Business Object and StrataFrame controls in User Control

http://forum.strataframe.net/Topic22669.aspx

By Jiri Brazda - 4/7/2009

I would like to use user controls in my web application. However I'm not able to bind strataframe components like textbox etc. on my user control to business object. In one of previous topics about this problem it was mentioned the following:

Web controls are a little different than winforms controls, but you can still use them. You can call whatever strataframe controls you need to inside of your web control, but you will have to take the binding for them into account in the render method of your web control. In winforms it handles the equivelant functions for you, but in web you have to do it yourself.

Outside of that, you're free to use them as you wish 

Could anybody put here a piece of code or a very simple sample that would demonstrate how to do it?

Thank You.

Jiri Brazda

By Trent L. Taylor - 4/8/2009

Well, this would depend on your user control, Jiri.  This comment is telling you that you will have to do one of hte following with your custom user control:

  1. Implement IWebBusinessBindable interface to your user control so that you can directly bind an SF BO.
  2. Make sure that your control supports a System.Web.UI.DataSourceControl and then bind to it using the WebBusinessBindingSource (SF control).

There are some other options as well.  But the first thing is that you need to come up with a way to bind your user control to either any binding source or an SF BO or both.  Once this is done, then it will make it easier to tell you what may need to be done within your user control.

By Jiri Brazda - 4/8/2009

OK, I'm trying the first alternative. My usercontrol implemments IWebBusinessBindable with necessary properties like BindingField, BusinessObjectName etc. However I do not know waht to do next? When I put SF TextBox on usercontrol surface and then try to set BusinessObjectName of the SF textbox, the following error is displayed:

InvalidCastException
  Unable to cast object of type 'System.Web.UI.UserControl' to type 'MicroFour.StrataFrame.UI.Web.IBasePage'.

Source     : MicroFour StrataFrame Extensibility

Stack Trace:
   at ᜅ..ctor(IWindowsFormsEditorService A_0, String A_1, Object A_2)
   at MicroFour.StrataFrame.Extensibility.BusinessObjectNameTypeEditor.EditValue(ITypeDescriptorContext context, IServiceProvider provider, Object value)

By Trent L. Taylor - 4/8/2009

Ah....yeah, you will have to implement IBasePage as well on your user control.  All SF webcontrols are expecting that implementation.  You can look at the BasePage class in the SF source to see how to implement it.