473,320 Members | 1,732 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Generic Control Validation

Ok, I've been looking through the .NET SDK docs and stuff.

I'm wondering if you can provide a control extender that does generic
validation or functionality just by dropping it on the form. For instance,
using the IExtenderProvider interface, you can specify properties, but there
is nothing documented about linking into a control's events.

For instance, in my application, there are specific formatting,
functionality and validation for all text boxes based on a couple of
property settings. Some of these text boxes have additional validation that
must be handled per control.

So, I want all my textboxes to automatically select all text when they get
tabbed into, on leaving, I want some generic special formatting applied
according to the property setting (if the data entered is in error,
automatically set the error provider to the error text (ie, invalid date,
invalid number, etc)). Some of this functionality (say allowing the
enter-key to move between fields).

Are we able to write an Extender control to do all of this in a generic
sense, intercept or handle certain control events, and still chain to the
normal control events? This would save a *ton* of coding, basically, just
drop the extender control on a form and set some fields and your entire
application has the same 'look-feel-functionality', and a common set of code
to adjust that without having to touch everything.

Reading a little more in the documentation, the ToolTop class seems to do
this, it pops up a tooltip if you hover over the control, but I can't see
any docs on how this is actually done.
Nov 20 '05 #1
5 2774
> I'm wondering if you can provide a control extender that does generic
validation or functionality just by dropping it on the form. For instance, using the IExtenderProvider interface, you can specify properties, but there is nothing documented about linking into a control's events.


When the SetWhatever method is called, of your Extender class, use
AddHandler to hook into the controls events:

Public Sub SetMyProperty(ByVal ctlControl As Control, ByVal Value As String)
Nov 20 '05 #2
Thank you, I just happened to page into a similar example in the SDK. So
now, my next question is, does the extender interface just automatically add
"Set" and "Get" as a prefix to the property name I give in order to set and
retrieve property values? I know that this is just a sub, and I know that
it "appears" to be doing that, but just wanted a confirmation.

So, basically, adding two properties, EnterKeyNextField and SelectOnEntry
would need extender property/methods called SetEnterKeyNextField,
GetEnterKeyNextField and SetSelectOnEntry, GetSelectOnEntry. There is no
other code required to tell it that those are the two sets of property
handlers.

"Tom Spink" <th**********@ntlworld.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I'm wondering if you can provide a control extender that does generic
validation or functionality just by dropping it on the form. For instance,
using the IExtenderProvider interface, you can specify properties, but

there
is nothing documented about linking into a control's events.


When the SetWhatever method is called, of your Extender class, use
AddHandler to hook into the controls events:

Public Sub SetMyProperty(ByVal ctlControl As Control, ByVal Value As

String) .
.
.
AddHandler ctlControl.GotFocus, AddressOf MyGotFocusHandlerProc
.
.
.
End Sub

Public Sub MyGotFocusHandlerProc(ByVal Sender As Object, ByVal e As
System.EventArgs)
.
.
.
End Sub

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

"Maybe it's a game called 'Punish the User'"
"Richard Brown" <rb****@easylift.org> wrote in message
news:e$**************@tk2msftngp13.phx.gbl...
Ok, I've been looking through the .NET SDK docs and stuff.

I'm wondering if you can provide a control extender that does generic
validation or functionality just by dropping it on the form. For

instance,
using the IExtenderProvider interface, you can specify properties, but

there
is nothing documented about linking into a control's events.

For instance, in my application, there are specific formatting,
functionality and validation for all text boxes based on a couple of
property settings. Some of these text boxes have additional validation

that
must be handled per control.

So, I want all my textboxes to automatically select all text when they get tabbed into, on leaving, I want some generic special formatting applied
according to the property setting (if the data entered is in error,
automatically set the error provider to the error text (ie, invalid date, invalid number, etc)). Some of this functionality (say allowing the
enter-key to move between fields).

Are we able to write an Extender control to do all of this in a generic
sense, intercept or handle certain control events, and still chain to the normal control events? This would save a *ton* of coding, basically, just drop the extender control on a form and set some fields and your entire
application has the same 'look-feel-functionality', and a common set of

code
to adjust that without having to touch everything.

Reading a little more in the documentation, the ToolTop class seems to do this, it pops up a tooltip if you hover over the control, but I can't see any docs on how this is actually done.


Nov 20 '05 #3
There should be an attribute attached to the Get method, and also to your
class:

<WatchForWrapping>

<ProvideProperty("Whatever", GetType(Control)) > _
Public Class MyExtenderClass
Inherits Component
Implements IExtenderProvider

<ExtenderProvidedProperty()> _
Public Function GetWhatever(ByVal ctlControl As Control) As String
Return "Foo"
End Function

Public Sub SetWhatever(ByVal ctlControl As Control, ByVal strValue As
String)
' Bar
End Sub

Public Function CanExtend(ByVal extendee As Object) As Boolean
Implements System.ComponentModel.IExtenderProvider.CanExtend

If TypeOf extendee Is Control Then
Return True
Else
Return False
End If

End Function

End Class

</WatchForWrapping>

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

"Maybe it's a game called 'Punish the User'"
"Richard Brown" <rb****@easylift.org> wrote in message
news:O6*************@tk2msftngp13.phx.gbl...
Thank you, I just happened to page into a similar example in the SDK. So
now, my next question is, does the extender interface just automatically add "Set" and "Get" as a prefix to the property name I give in order to set and retrieve property values? I know that this is just a sub, and I know that
it "appears" to be doing that, but just wanted a confirmation.

So, basically, adding two properties, EnterKeyNextField and SelectOnEntry
would need extender property/methods called SetEnterKeyNextField,
GetEnterKeyNextField and SetSelectOnEntry, GetSelectOnEntry. There is no
other code required to tell it that those are the two sets of property
handlers.

"Tom Spink" <th**********@ntlworld.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I'm wondering if you can provide a control extender that does generic
validation or functionality just by dropping it on the form. For

instance,
using the IExtenderProvider interface, you can specify properties, but

there
is nothing documented about linking into a control's events.


When the SetWhatever method is called, of your Extender class, use
AddHandler to hook into the controls events:

Public Sub SetMyProperty(ByVal ctlControl As Control, ByVal Value As

String)
.
.
.
AddHandler ctlControl.GotFocus, AddressOf MyGotFocusHandlerProc
.
.
.
End Sub

Public Sub MyGotFocusHandlerProc(ByVal Sender As Object, ByVal e As
System.EventArgs)
.
.
.
End Sub

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

"Maybe it's a game called 'Punish the User'"
"Richard Brown" <rb****@easylift.org> wrote in message
news:e$**************@tk2msftngp13.phx.gbl...
Ok, I've been looking through the .NET SDK docs and stuff.

I'm wondering if you can provide a control extender that does generic
validation or functionality just by dropping it on the form. For

instance,
using the IExtenderProvider interface, you can specify properties, but

there
is nothing documented about linking into a control's events.

For instance, in my application, there are specific formatting,
functionality and validation for all text boxes based on a couple of
property settings. Some of these text boxes have additional validation
that
must be handled per control.

So, I want all my textboxes to automatically select all text when they get tabbed into, on leaving, I want some generic special formatting
applied according to the property setting (if the data entered is in error,
automatically set the error provider to the error text (ie, invalid date, invalid number, etc)). Some of this functionality (say allowing the
enter-key to move between fields).

Are we able to write an Extender control to do all of this in a generic sense, intercept or handle certain control events, and still chain to the normal control events? This would save a *ton* of coding, basically, just drop the extender control on a form and set some fields and your entire application has the same 'look-feel-functionality', and a common set
of code
to adjust that without having to touch everything.

Reading a little more in the documentation, the ToolTop class seems to

do this, it pops up a tooltip if you hover over the control, but I can't see any docs on how this is actually done.



Nov 20 '05 #4
Ok, going the wrong way now.... I'm more confused, sorry...

The documentation says that the <ExtenderProvidedProperty()> is for support
of the .NET framework and should not be used in my code. Also, I *still* do
not see a specific statement that says "SetWhatever" is used to set the
"Whatever" property. My question was, does the .NET Framework *imply* that
if you extend a property "Whatever", you must have a method or function of
"SetWhatever" for it to work correctly? Or is there something that you
specifiy to link a specific property name to a specific handler function?

"Tom Spink" <th**********@ntlworld.com> wrote in message
news:uk**************@TK2MSFTNGP11.phx.gbl...
There should be an attribute attached to the Get method, and also to your
class:

<WatchForWrapping>

<ProvideProperty("Whatever", GetType(Control)) > _
Public Class MyExtenderClass
Inherits Component
Implements IExtenderProvider

<ExtenderProvidedProperty()> _
Public Function GetWhatever(ByVal ctlControl As Control) As String
Return "Foo"
End Function

Public Sub SetWhatever(ByVal ctlControl As Control, ByVal strValue As
String)
' Bar
End Sub

Public Function CanExtend(ByVal extendee As Object) As Boolean
Implements System.ComponentModel.IExtenderProvider.CanExtend

If TypeOf extendee Is Control Then
Return True
Else
Return False
End If

End Function

End Class

</WatchForWrapping>

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

"Maybe it's a game called 'Punish the User'"
"Richard Brown" <rb****@easylift.org> wrote in message
news:O6*************@tk2msftngp13.phx.gbl...
Thank you, I just happened to page into a similar example in the SDK. So
now, my next question is, does the extender interface just automatically

add
"Set" and "Get" as a prefix to the property name I give in order to set

and
retrieve property values? I know that this is just a sub, and I know that it "appears" to be doing that, but just wanted a confirmation.

So, basically, adding two properties, EnterKeyNextField and SelectOnEntry would need extender property/methods called SetEnterKeyNextField,
GetEnterKeyNextField and SetSelectOnEntry, GetSelectOnEntry. There is no other code required to tell it that those are the two sets of property
handlers.

"Tom Spink" <th**********@ntlworld.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
> I'm wondering if you can provide a control extender that does generic > validation or functionality just by dropping it on the form. For
instance,
> using the IExtenderProvider interface, you can specify properties, but there
> is nothing documented about linking into a control's events.

When the SetWhatever method is called, of your Extender class, use
AddHandler to hook into the controls events:

Public Sub SetMyProperty(ByVal ctlControl As Control, ByVal Value As

String)
.
.
.
AddHandler ctlControl.GotFocus, AddressOf MyGotFocusHandlerProc
.
.
.
End Sub

Public Sub MyGotFocusHandlerProc(ByVal Sender As Object, ByVal e As
System.EventArgs)
.
.
.
End Sub

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

"Maybe it's a game called 'Punish the User'"
"Richard Brown" <rb****@easylift.org> wrote in message
news:e$**************@tk2msftngp13.phx.gbl...
> Ok, I've been looking through the .NET SDK docs and stuff.
>
> I'm wondering if you can provide a control extender that does generic > validation or functionality just by dropping it on the form. For
instance,
> using the IExtenderProvider interface, you can specify properties, but there
> is nothing documented about linking into a control's events.
>
> For instance, in my application, there are specific formatting,
> functionality and validation for all text boxes based on a couple of
> property settings. Some of these text boxes have additional validation that
> must be handled per control.
>
> So, I want all my textboxes to automatically select all text when
they get
> tabbed into, on leaving, I want some generic special formatting applied > according to the property setting (if the data entered is in error,
> automatically set the error provider to the error text (ie, invalid

date,
> invalid number, etc)). Some of this functionality (say allowing the
> enter-key to move between fields).
>
> Are we able to write an Extender control to do all of this in a generic > sense, intercept or handle certain control events, and still chain
to the
> normal control events? This would save a *ton* of coding,
basically, just
> drop the extender control on a form and set some fields and your entire > application has the same 'look-feel-functionality', and a common set of code
> to adjust that without having to touch everything.
>
> Reading a little more in the documentation, the ToolTop class seems

to do
> this, it pops up a tooltip if you hover over the control, but I
can't see
> any docs on how this is actually done.
>
>



Nov 20 '05 #5
> The documentation says that the <ExtenderProvidedProperty()> is for
support
of the .NET framework and should not be used in my code.
Okay, I can live with that. I just didn't see it in the docs when I was
messing with the Extender.
My question was, does the .NET Framework *imply* that
if you extend a property "Whatever", you must have a method or function of
"SetWhatever" for it to work correctly? Or is there something that you
specifiy to link a specific property name to a specific handler function?
Basically, Yes. That's it!! The SetWhatever and GetWhatever are
automatically attached to the property ('Whatever') you are extending. It's
just like a property statement block:

Property Foo() As Bar
Get
Return Moo
End Get
Set (Value As Bar)
Moo = Value
End Set
End Property

There are actually two methods created and compiled into your application,
when compiled... get_Foo and set_Foo.

Try a bit of proof (in the IDE):

Property Foo() As Integer
Get
Return 10
End Get
Set (Value As Bar)
' Do nothing
End Set
End Property

Function get_Foo() As Integer
Return 100
End Function

The IDE wavy line's the property and tells me off, because I have a get_Foo,
which is implicitally defined by the Property.

If you think of it like that, then it's not so bad. Your SetWhatever and
GetWhatever will automatically be attached to the property you are
extending.

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

"Maybe it's a game called 'Punish the User'"
"Richard Brown" <rb****@easylift.org> wrote in message
news:OG**************@TK2MSFTNGP11.phx.gbl... Ok, going the wrong way now.... I'm more confused, sorry...

The documentation says that the <ExtenderProvidedProperty()> is for support of the .NET framework and should not be used in my code. Also, I *still* do not see a specific statement that says "SetWhatever" is used to set the
"Whatever" property. My question was, does the .NET Framework *imply* that if you extend a property "Whatever", you must have a method or function of
"SetWhatever" for it to work correctly? Or is there something that you
specifiy to link a specific property name to a specific handler function?

"Tom Spink" <th**********@ntlworld.com> wrote in message
news:uk**************@TK2MSFTNGP11.phx.gbl...
There should be an attribute attached to the Get method, and also to your
class:

<WatchForWrapping>

<ProvideProperty("Whatever", GetType(Control)) > _
Public Class MyExtenderClass
Inherits Component
Implements IExtenderProvider

<ExtenderProvidedProperty()> _
Public Function GetWhatever(ByVal ctlControl As Control) As String
Return "Foo"
End Function

Public Sub SetWhatever(ByVal ctlControl As Control, ByVal strValue As String)
' Bar
End Sub

Public Function CanExtend(ByVal extendee As Object) As Boolean
Implements System.ComponentModel.IExtenderProvider.CanExtend

If TypeOf extendee Is Control Then
Return True
Else
Return False
End If

End Function

End Class

</WatchForWrapping>

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

"Maybe it's a game called 'Punish the User'"
"Richard Brown" <rb****@easylift.org> wrote in message
news:O6*************@tk2msftngp13.phx.gbl...
Thank you, I just happened to page into a similar example in the SDK. So now, my next question is, does the extender interface just automatically add
"Set" and "Get" as a prefix to the property name I give in order to
set
and
retrieve property values? I know that this is just a sub, and I know that it "appears" to be doing that, but just wanted a confirmation.

So, basically, adding two properties, EnterKeyNextField and SelectOnEntry would need extender property/methods called SetEnterKeyNextField,
GetEnterKeyNextField and SetSelectOnEntry, GetSelectOnEntry. There is no other code required to tell it that those are the two sets of property
handlers.

"Tom Spink" <th**********@ntlworld.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
> > I'm wondering if you can provide a control extender that does generic > > validation or functionality just by dropping it on the form. For
> instance,
> > using the IExtenderProvider interface, you can specify properties, but > there
> > is nothing documented about linking into a control's events.
>
> When the SetWhatever method is called, of your Extender class, use
> AddHandler to hook into the controls events:
>
> Public Sub SetMyProperty(ByVal ctlControl As Control, ByVal Value As
String)
> .
> .
> .
> AddHandler ctlControl.GotFocus, AddressOf MyGotFocusHandlerProc
> .
> .
> .
> End Sub
>
> Public Sub MyGotFocusHandlerProc(ByVal Sender As Object, ByVal e As
> System.EventArgs)
> .
> .
> .
> End Sub
>
> --
> HTH,
> -- Tom Spink, Über Geek
>
> Please respond to the newsgroup,
> so all can benefit
>
> "Maybe it's a game called 'Punish the User'"
>
>
> "Richard Brown" <rb****@easylift.org> wrote in message
> news:e$**************@tk2msftngp13.phx.gbl...
> > Ok, I've been looking through the .NET SDK docs and stuff.
> >
> > I'm wondering if you can provide a control extender that does generic > > validation or functionality just by dropping it on the form. For
> instance,
> > using the IExtenderProvider interface, you can specify properties, but > there
> > is nothing documented about linking into a control's events.
> >
> > For instance, in my application, there are specific formatting,
> > functionality and validation for all text boxes based on a couple
of > > property settings. Some of these text boxes have additional validation
> that
> > must be handled per control.
> >
> > So, I want all my textboxes to automatically select all text when

they get
> > tabbed into, on leaving, I want some generic special formatting

applied
> > according to the property setting (if the data entered is in error, > > automatically set the error provider to the error text (ie, invalid date,
> > invalid number, etc)). Some of this functionality (say allowing the > > enter-key to move between fields).
> >
> > Are we able to write an Extender control to do all of this in a

generic
> > sense, intercept or handle certain control events, and still chain to the
> > normal control events? This would save a *ton* of coding, basically, just
> > drop the extender control on a form and set some fields and your

entire
> > application has the same 'look-feel-functionality', and a common
set of
> code
> > to adjust that without having to touch everything.
> >
> > Reading a little more in the documentation, the ToolTop class

seems to do
> > this, it pops up a tooltip if you hover over the control, but I can't see
> > any docs on how this is actually done.
> >
> >
>
>



Nov 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Weston C | last post by:
I'm trying to write a generic/reusable form validator in Javascript... just something that checks to make sure required fields have a value. By generic I mean I don't want to explicitly reference...
6
by: Nedu N | last post by:
Hi, I want to have confirmation(Yes/No) on a button of the webform in which there are many validation controls. I want all the validation controls to be triggered first and then Yes/No...
2
by: Pham Nguyen | last post by:
Has anyone seen an example of a textbox server control that has built-in client-side validation? I'd like to build a server control that extends the System.Web.UI.WebControls.TextBox class to allow...
7
by: A.M | last post by:
Hi, I have a validation control in my page that upon any invalid data, it disables all buttons in the page. basicly i don't have any postback in the page if the validator finds any error. How...
2
by: Barbara Alderton | last post by:
I setup some standard Required Field Validation controls and one Custom validation control on an ASP.NET page (within a user control) to validate text entry. I also setup a Summary Control to post...
2
by: c676228 | last post by:
Hi, I have several user controls like email, phone,ssn etc. each has it's own validation message in its user control already. When I bring all those user controls in an aspx page, I would like to...
1
by: sam | last post by:
Hi all, I am looking for a generic form validation script for my personal project. I found few out there in search but nothing too close to what I want. If I have a form in a page I want to...
3
by: Seth Gecko | last post by:
Hi I am working with generic lists of various objects and a control dealing with these lists. For instance: A parent form holds: dim Walls as List(Of wall) dim Segments as List(Of segment) ...
0
by: sloan | last post by:
Is anyone else using the Microsoft Practices EnterpriseLibrary conventions for naming FILES (.cs) as far as a non-generic and generic implementation is concerned? Anyone have an alternative? ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.