Use business object in UserControl


Author
Message
Olivier
Olivier
StrataFrame User (324 reputation)StrataFrame User (324 reputation)StrataFrame User (324 reputation)StrataFrame User (324 reputation)StrataFrame User (324 reputation)StrataFrame User (324 reputation)StrataFrame User (324 reputation)StrataFrame User (324 reputation)StrataFrame User (324 reputation)
Group: StrataFrame Users
Posts: 96, Visits: 805
Hello

I use a base class AppBasePage inherit of MicroFour.StrataFrame.UI.Web.BasePage,
it's ok , i can use my business object .

But if i have a UserControl , how i can Bind textbox and save to in Business object,

have you a good way to work with userControl. and Business Object on the Webform.

Thanks
Olivier,

==============================================
Asp.net C# - Strataframe - telerik
==============================================
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Oliver:

You can most definitely create a user control and bind to it.  In fact, there are several ways that you can learn more about this.  You need to implement the IBusinessBindable interface to your user control.  If you search the forum, you will see a ton of posts.  But there are also some samples that come with the framework showing you exactly how to implement the IBusinessBindable interface on a control.

Also, you can open the source code and look at the StrataFrame textbox or any other SF web control, and you can see how the IBusinessBindable was implemented and then add this to your own control.  Honestly, most times I implement IBusinessBindable myself on a new user control, I will go copy the implementation from another class and then make the changes necessary.
Olivier
Olivier
StrataFrame User (324 reputation)StrataFrame User (324 reputation)StrataFrame User (324 reputation)StrataFrame User (324 reputation)StrataFrame User (324 reputation)StrataFrame User (324 reputation)StrataFrame User (324 reputation)StrataFrame User (324 reputation)StrataFrame User (324 reputation)
Group: StrataFrame Users
Posts: 96, Visits: 805
Hello Trent

There are some sample ? here : C:\Program Files\MicroFour\StrataFrame\CSharp Samples ?  in WebForm ?

You have a solution to have a Base Class for UserControl ?

Your base class UserControl work with appbasepage ?

Thanks
Olivier,

==============================================
Asp.net C# - Strataframe - telerik
==============================================
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Oliver:

Whether you are working in WinForms or WebForms, the implementation will be basically the same.  I think I did mislead you a little on the previous post because you will want to use the IWebBusinessBindable on the web side of things.  From your post, I assume that you are creating a custom user control, and then wanting to bind to that control.  My brain was on the WinForms side of things, but here, you are wanting to do web.  But the process is the same.

For example, you may want to start with a WebControl as your base class, not a UserControl like on the WinForms.  It depends on what you are trying to accomplish in your application.  But for example:

using System;
using System.Collections.Generic;
using System.Text;
using MicroFour.StrataFrame.UI.Web;

namespace TestingWebControl
{
    public class MyCustomWebControl : System.Web.UI.WebControls.WebControl, IWebBusinessBindable
    {

        #region IWebBusinessBindable Members

        public bool BindingEditable
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public string ErrorMessage
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public bool HasAdditionalBindings
        {
            get { throw new NotImplementedException(); }
        }

        public bool IgnoreManageUIReadOnlyState
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public bool InError
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        #endregion

        #region IWebBinding Members

        public MicroFour.StrataFrame.UI.BindingDirections BindingDirection
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public string BindingField
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public string BindingFormat
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public string BindingProperty
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public string BusinessObjectName
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        #endregion

    }
}


The code above is a new web control that I created and then I implemented IWebBusinessBindable.  Next, you can save a lot of time by opening the SF source code and pulling the implementation code from a web control, such as a textbox.  So here in the next step, I started to "flesh" this out a little by creating the private fields and start implementing the properties using the type editors, etc. that are already built and ready for you to use through StrataFrame.

using System;
using System.Collections.Generic;
using System.Text;
using MicroFour.StrataFrame.UI.Web;
using MicroFour.StrataFrame.UI;
using System.ComponentModel;
using MicroFour.StrataFrame.Business;
using MicroFour.StrataFrame.Extensibility;
using System.Drawing.Design;

namespace TestingWebControl
{
    public class MyCustomWebControl : System.Web.UI.WebControls.WebControl, IWebBusinessBindable
    {

        #region [ Private Fields ]
       
        string _BindingField  = string.Empty;
        string _BindingProperty = "Text";
        string _BindingFormat = string.Empty;
        string _BusinessObjectName = string.Empty;
        BindingDirections _BindingDirection = BindingDirections.TwoWay;
        string _ErrorMessage = string.Empty;
        bool _InError = false;
        bool _IgnoreManageUIReadOnlyState = false;

        #endregion


        #region IWebBusinessBindable Members

        public bool BindingEditable
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public string ErrorMessage
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public bool HasAdditionalBindings
        {
            get { throw new NotImplementedException(); }
        }

        public bool IgnoreManageUIReadOnlyState
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public bool InError
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        #endregion

        #region IWebBinding Members

        public MicroFour.StrataFrame.UI.BindingDirections BindingDirection
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        [Category(BusinessMod.EDITOR_CATEGORY)]
        [DefaultValue("")]
        [Description(BusinessMod.EDITOR_BINDINGFIELD_DESC)]
        [Editor(Constants.TE_WebBindingFieldTypeEditor, typeof(UITypeEditor))]
        public string BindingField
        {
            get
            {
                return _BindingField;
            }
            set
            {
                _BindingField = value;
            }
        }

        [Category(BusinessMod.EDITOR_CATEGORY)]
        [DefaultValue("")]
        [Description(BusinessMod.EDITOR_WEBBINDINGFORMAT_DESC)]
        public string BindingFormat
        {
            get
            {
                return _BindingFormat;
            }
            set
            {
                _BindingFormat = value;
            }
        }

        [Category(BusinessMod.EDITOR_CATEGORY)]
        [DefaultValue("")]
        [Description(BusinessMod.EDITOR_BINDINGPROPERTY_DESC)]
        [Editor(Constants.TE_BindingPropertyEditor, typeof(UITypeEditor))]
        public string BindingProperty
        {
            get
            {
                return _BindingProperty;
            }
            set
            {
                _BindingProperty = value;
            }
        }

        [Category(BusinessMod.EDITOR_CATEGORY)]
        [DefaultValue("")]
        [Description(BusinessMod.EDITOR_BUSINESSOBJECT_DESC)]
        [Editor(Constants.TE_BusinessObjectNameTypeEditor, typeof(UITypeEditor))]
        public string BusinessObjectName
        {
            get
            {
                return _BusinessObjectName;
            }
            set
            {
                _BusinessObjectName = value;
            }
        }


        #endregion

    }
}


You can see the highlighted changes.  At this point, you just continue to pull out of the SF code until you complete the implementation of the control.  Next, you will want to bind to a property that represents the data in your control.  This will be the BindingProperty of the implementation.  So you can change the default value to meet your needs, but after that, SF should hook up and bind for you on your custom control.

I hope that this helps.
Olivier
Olivier
StrataFrame User (324 reputation)StrataFrame User (324 reputation)StrataFrame User (324 reputation)StrataFrame User (324 reputation)StrataFrame User (324 reputation)StrataFrame User (324 reputation)StrataFrame User (324 reputation)StrataFrame User (324 reputation)StrataFrame User (324 reputation)
Group: StrataFrame Users
Posts: 96, Visits: 805
Hello Trent,

Really i don't understand your method.

I would like to access of my Business Object From WebUserControl store in page parent .

My WebForm inherit from AppBasePage which store all the Bo,
and from my Webusercontrol , can i access this ?

thanks
Olivier,

==============================================
Asp.net C# - Strataframe - telerik
==============================================
Olivier
Olivier
StrataFrame User (324 reputation)StrataFrame User (324 reputation)StrataFrame User (324 reputation)StrataFrame User (324 reputation)StrataFrame User (324 reputation)StrataFrame User (324 reputation)StrataFrame User (324 reputation)StrataFrame User (324 reputation)StrataFrame User (324 reputation)
Group: StrataFrame Users
Posts: 96, Visits: 805
Hello trent,

i understand your code, it's implement a custom control with the iWebBusinnessBindable,
very good for my telerik control.

But Have you a solution to get an access of my businness Object global (AppBasPage) from my WebUserControl ?

thanks
Olivier,

==============================================
Asp.net C# - Strataframe - telerik
==============================================
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search