StrataFrame Forum

Use Control Inherits From StrataFrame Library

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

By Wang Tong Yin - 7/3/2006

Can I use my own control, which inherits from StrataFrame library? For example, I define a class called 'Textbox' as below:

Public Class Textbox

     Inherits MicroFour.StrataFrame.UI.Web.TextBox

     .

     .

     .

End Class

 

Will it cause any errors when i try to add, update or delete record?

By StrataFrame Team - 7/3/2006

Nope, no problems at all... have fun with that.

Also, if you need to create your own controls that are bindable to business objects in the framework, you only need to implement the IWebBusinessBindable interface on your control and use the source code for the TextBox or any of the other controls to see how to implement it (type editor attributes, extra code, etc.).

By Wang Tong Yin - 7/3/2006

I try to change something on the web controls before displaying them. For example, the value of a textbox will be updated by a function before it shows out. Can I add my code in some event functions like Textbox_Init() and Textbox_Load() as shown below?

Private Sub Textbox_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init

End Sub

Private Sub Textbox_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

End Sub

Will it affect the original behavior of strataframe control? Does Strataframe add any code in event functions? Is there any better way to do it? Does Strataframe provide any hook method like before display, after display?

By StrataFrame Team - 7/5/2006

No, the web controls do not have any hooks for the databinding.

The data is copied through the binding to the control on the Page.PreRender event and the data is copied back from the control on a PostBack through the Page.PreLoad event.  So, after the PreRender event, the controls will be populated with the appropriate values for the binding, and successfully modify the value by altering the control after the Page.PreRender event.  Same thing goes for the Page.PreLoad event for copying data back from the control.

By Wang Tong Yin - 7/6/2006

1. This means StrataFrame will update and modify the value of the controls in Page.PreLoad and Page.PreRender event?

2. What will happen if I add code in Page.PreLoad and Page.PreRender event? If error may occur, what I should do to prevent the error?

3. Page.Load and Page.PreRenderComplete are the safe places for me to add some codes?

By StrataFrame Team - 7/6/2006

This means StrataFrame will update and modify the value of the controls in Page.PreLoad and Page.PreRender event?

That is correct.

What will happen if I add code in Page.PreLoad and Page.PreRender event? If error may occur, what I should do to prevent the error?

You could add code there.  You should handle errors just like any other errors that appear within an ASP.NET page, including the custom error pages if necessary.

Page.Load and Page.PreRenderComplete are the safe places for me to add some codes?

Correct, those are the safest places to add code.

By Wang Tong Yin - 7/6/2006

In foxpro we can use DODEFAULT() function to execute parent event or method. This can prevent child class from overwriting the codes in parent class. How to do this in VB.Net?
By StrataFrame Team - 7/7/2006

When you override a method, you have to call MyBase.MethodName().  So, if you're overriding the OnPaint() method of a control, it would look like this:

Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
    '-- Make the base method call (DODEFAULT())
    MyBase.OnPaint(e)

    '-- Custom code here
End Sub

Now, if you attach to an event, then there is no base or DODEFAULT that you need to call; it will be done automatically.  In fact, there is no way to prevent the base methods from firing.  Only on method overrides do you need to call the base method.