Null Dates in Webforms, How?
 
Home My Account Forum Try It! Buy It!
About Contact Us Site Map
StrataFrame Forum
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      


««12

Null Dates in Webforms, How?Expand / Collapse
Author
Message
Posted 01/28/2008 8:49:11 PM
StrataFrame VIP

StrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIP

Group: StrataFrame Users
Last Login: Today @ 3:11:51 PM
Posts: 1,148, Visits: 2,831
You just create a class that is named whatever you like and inherit that class from the control you are sub classing:

' VB
Public Class MyTextbox
Inherits Microfour.StrataFrame.UI.Windows.Forms.Textbox
' code...
End Class

// C#
class MyTextbox : Microfour.StrataFrame.UI.Windows.Forms.TextBox {
// code...
}


This will then available in the toolbox under the project you put it in (each project that has controls, user controls or components will be a heading in the toolbox).
Post #13807
Posted 01/29/2008 9:14:18 AM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Today @ 11:54:01 AM
Posts: 4,104, Visits: 4,177
Sometimes I wonder why I'm doing this, as subclassing a control like this was so easy to do in VFP.

As a former VFP developer...it is actually MUCH easier in .NET once you understand the structure of .NET.  Greg's sample is spot on...just create a class, then inherit whatever base class that you would like.  You can then override base functionality (which is much better then VFP ever was in this area, especially as it relates to events).  For example, if I inherit a TextBox and want to change the logic (or add to) of the TextChanged event I could do this:

Public Class MyTextBox
    Inherits MicroFour.StrataFrame.UI.Windows.Forms.TextBox

    Protected Overrides Sub OnTextChanged(ByVal sender As Object, ByVal e As EventArgs)
       MyBase.OnTextChanged(sender, e)

       '-- Add your logic here (or above the base if that is what your require....You can also skip the base logic altogether
       '    if that is in fact what you are trying to accomplish.
    End Sub
End Class

Post #13820
Posted 01/30/2008 8:19:56 PM
StrataFrame Beginner

StrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame Beginner

Group: StrataFrame Users
Last Login: 07/01/2008 5:46:16 PM
Posts: 20, Visits: 77
This is all well and good, but all the examples seem to be for windows forms and don't seem to work for webforms.  All I want to do it subclass the control and be able to place it in my webform in place of the normal control.  I can't seem to do anything with a control created this way.  Am I missing something or is VS2005 broken on both my desktop and laptop?
Post #13852
Posted 01/31/2008 9:37:06 AM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Today @ 11:54:01 AM
Posts: 4,104, Visits: 4,177
Cyrus,

This is no different for web than it is for Windows.  The only difference is that you will want to create a class library that your web site or web application references to house all of your custom (or inherited) controls.  Here is how you would subclass a web textbox:

Public Class MyWebTextBox
    Inherits MicroFour.StrataFrame.UI.Web.TextBox
    Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
        MyBase.OnTextChanged(e)
    End Sub
End Class
Post #13862
Posted 02/04/2008 11:51:11 PM
StrataFrame Beginner

StrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame Beginner

Group: StrataFrame Users
Last Login: 07/01/2008 5:46:16 PM
Posts: 20, Visits: 77
Trent L. Taylor (01/31/2008)
Cyrus,

This is no different for web than it is for Windows.  The only difference is that you will want to create a class library that your web site or web application references to house all of your custom (or inherited) controls.  Here is how you would subclass a web textbox:

Public Class MyWebTextBox
    Inherits MicroFour.StrataFrame.UI.Web.TextBox
    Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
        MyBase.OnTextChanged(e)
    End Sub
End Class

Ok, I've tried that without any success.  Does it have to be in it's own assembly to work?  When I create the subclass for the textbox I can't find any way to put it on a webform and actually use it.  This is where things are geting stuck.  Once I have created the subclassed control how do I use it, since I'm guessing that I have the subclassed control now, but I can't put on anything and use it.

Post #13996
Posted 02/05/2008 9:55:44 AM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Today @ 11:54:01 AM
Posts: 4,104, Visits: 4,177
Cyrus,

Once you create the class, make sure that your web application has a reference to the assembly that houses the class you created.  You can also turn on the AutoPopulateToolbox option for it to show in your toolbox...or just type in the name of the namespace and class when defining the object.

To turn on the AutoPopulation of the toolbox click Tools->Options->Windows Forms Designer->General->AutoToolboxPopulate .

I know that it says "Windows Forms" but this populates the Web controls as well.

Post #14004
Posted 02/08/2008 5:41:59 PM
StrataFrame Beginner

StrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame Beginner

Group: StrataFrame Users
Last Login: 07/01/2008 5:46:16 PM
Posts: 20, Visits: 77
Trent L. Taylor (02/05/2008)
Cyrus,

Once you create the class, make sure that your web application has a reference to the assembly that houses the class you created.  You can also turn on the AutoPopulateToolbox option for it to show in your toolbox...or just type in the name of the namespace and class when defining the object.

To turn on the AutoPopulation of the toolbox click Tools->Options->Windows Forms Designer->General->AutoToolboxPopulate .

I know that it says "Windows Forms" but this populates the Web controls as well.

Just to clarify what I am going to try here, I do need to create a seperate assembly containing any subclassed controls I want to use and then I can reference them and use the controls?  I think I can work with that.  I have some other questions on whether I can do some things or not but I'll start another thread for that.

Post #14226
Posted 02/09/2008 11:50:04 AM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Today @ 11:54:01 AM
Posts: 4,104, Visits: 4,177
I do need to create a seperate assembly containing any subclassed controls I want to use and then I can reference them and use the controls?

Yup...this is exactly what you should do.  This is the very same thing that we do for all of our applications as well as our web applications.  So just create a class library, add all of your subclassed controls, then you can use them instead of the standard controls.  This is good programming standards...good job

Post #14238
« Prev Topic | Next Topic »

««12

Reading This TopicExpand / Collapse
Active Users: 0 (0 guests,