471,119 Members | 1,446 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Form Validation From Business Object

All,

Not sure if I'm taking the correct approach or not, but here it is...

I have my business object with a property. I want to validate the Setting
of this property with the business object. This works fine. I then create
a Form, put a TextBox control on it, add a DataBinding to the control to the
business object's property. When the control is displayed, it sets the text
to the property's get - perfect. When I type something in the textbox and
tab off of it, it calls the Set part of the property, which validates the
value and throws an exception. Where does this exception go? It doesn't
seem to go anywhere - as if the internal .net code has a try...catch, but is
not doing anything with the exception.

Is this even the correct approach for control validation? I have to have
the validation in the business object and I don't want to have to re-write
it again in the GUI.

Any help is appreciated!

Dave
Nov 20 '05 #1
7 1170
Sorry,

I meant to post some source code:

Public Class MyTestClass
Public Property Test() As String
Get
Return "Test"
End Get
Set(ByVal Value As String)
Throw New System.Exception("This is an exception")
End Set
End Property
End Class

Create a window with a button and a textbox. Here's my binding code:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs Handles Button1.Click
Dim o As New MyTestClass
Me.TextBox1.DataBindings.Add("Text", o, "Test")
End Sub

Thanks in advance...
Dave
"Dave Wurtz" <da*******************@asdsoftware.com> wrote in message
news:3f******@news.splitrock.net...
All,

Not sure if I'm taking the correct approach or not, but here it is...

I have my business object with a property. I want to validate the Setting
of this property with the business object. This works fine. I then create a Form, put a TextBox control on it, add a DataBinding to the control to the business object's property. When the control is displayed, it sets the text to the property's get - perfect. When I type something in the textbox and
tab off of it, it calls the Set part of the property, which validates the
value and throws an exception. Where does this exception go? It doesn't
seem to go anywhere - as if the internal .net code has a try...catch, but is not doing anything with the exception.

Is this even the correct approach for control validation? I have to have
the validation in the business object and I don't want to have to re-write
it again in the GUI.

Any help is appreciated!

Dave

Nov 20 '05 #2
Lets see the validation code in the Object Dave...
--
Ibrahim Malluf
http://www.malluf.com
==============================================
MCS Data Services Code Generator
http://64.78.34.175/mcsnet/DSCG/Announcement.aspx
==============================================

"Dave Wurtz" <da*******************@asdsoftware.com> wrote in message
news:3f******@news.splitrock.net...
All,

Not sure if I'm taking the correct approach or not, but here it is...

I have my business object with a property. I want to validate the Setting
of this property with the business object. This works fine. I then create a Form, put a TextBox control on it, add a DataBinding to the control to the business object's property. When the control is displayed, it sets the text to the property's get - perfect. When I type something in the textbox and
tab off of it, it calls the Set part of the property, which validates the
value and throws an exception. Where does this exception go? It doesn't
seem to go anywhere - as if the internal .net code has a try...catch, but is not doing anything with the exception.

Is this even the correct approach for control validation? I have to have
the validation in the business object and I don't want to have to re-write
it again in the GUI.

Any help is appreciated!

Dave

Nov 20 '05 #3
Dave,

As a suggestion you might want to look at Rockfort Lhota's book on Business
Objects. I like and have used his method (abiet modified) for a BrokenRules
class.

Dan

"Dave Wurtz" <da*******************@asdsoftware.com> wrote in message
news:3f******@news.splitrock.net...
All,

Not sure if I'm taking the correct approach or not, but here it is...

I have my business object with a property. I want to validate the Setting
of this property with the business object. This works fine. I then create a Form, put a TextBox control on it, add a DataBinding to the control to the business object's property. When the control is displayed, it sets the text to the property's get - perfect. When I type something in the textbox and
tab off of it, it calls the Set part of the property, which validates the
value and throws an exception. Where does this exception go? It doesn't
seem to go anywhere - as if the internal .net code has a try...catch, but is not doing anything with the exception.

Is this even the correct approach for control validation? I have to have
the validation in the business object and I don't want to have to re-write
it again in the GUI.

Any help is appreciated!

Dave

Nov 20 '05 #4
Dan,

Thanks for the suggestion.

What is the title of this book? Do you have a ISBN number?

Dave

"solex" <so***@nowhere.com> wrote in message
news:ef**************@TK2MSFTNGP10.phx.gbl...
Dave,

As a suggestion you might want to look at Rockfort Lhota's book on Business Objects. I like and have used his method (abiet modified) for a BrokenRules class.

Dan

"Dave Wurtz" <da*******************@asdsoftware.com> wrote in message
news:3f******@news.splitrock.net...
All,

Not sure if I'm taking the correct approach or not, but here it is...

I have my business object with a property. I want to validate the Setting of this property with the business object. This works fine. I then create
a Form, put a TextBox control on it, add a DataBinding to the control to

the
business object's property. When the control is displayed, it sets the

text
to the property's get - perfect. When I type something in the textbox and tab off of it, it calls the Set part of the property, which validates the value and throws an exception. Where does this exception go? It doesn't seem to go anywhere - as if the internal .net code has a try...catch, but is
not doing anything with the exception.

Is this even the correct approach for control validation? I have to

have the validation in the business object and I don't want to have to re-write it again in the GUI.

Any help is appreciated!

Dave


Nov 20 '05 #5
Visual Basic 6 Business Object (I believe he has one for dotNet, but the
methods still apply) ISBN 1-861001-07-X

Dan

"Dave Wurtz" <da*******************@asdsoftware.com> wrote in message
news:3f********@news.splitrock.net...
Dan,

Thanks for the suggestion.

What is the title of this book? Do you have a ISBN number?

Dave

"solex" <so***@nowhere.com> wrote in message
news:ef**************@TK2MSFTNGP10.phx.gbl...
Dave,

As a suggestion you might want to look at Rockfort Lhota's book on

Business
Objects. I like and have used his method (abiet modified) for a

BrokenRules
class.

Dan

"Dave Wurtz" <da*******************@asdsoftware.com> wrote in message
news:3f******@news.splitrock.net...
All,

Not sure if I'm taking the correct approach or not, but here it is...

I have my business object with a property. I want to validate the Setting of this property with the business object. This works fine. I then

create
a Form, put a TextBox control on it, add a DataBinding to the control
to
the
business object's property. When the control is displayed, it sets
the text
to the property's get - perfect. When I type something in the textbox

and tab off of it, it calls the Set part of the property, which validates the value and throws an exception. Where does this exception go? It doesn't seem to go anywhere - as if the internal .net code has a try...catch, but
is
not doing anything with the exception.

Is this even the correct approach for control validation? I have to

have the validation in the business object and I don't want to have to re-write it again in the GUI.

Any help is appreciated!

Dave



Nov 20 '05 #6
Sorry,

I meant to post some source code:

Public Class MyTestClass
Public Property Test() As String
Get
Return "Test"
End Get
Set(ByVal Value As String)
Throw New System.Exception("This is an exception")
End Set
End Property
End Class

Create a window with a button and a textbox. Here's my binding code:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs Handles Button1.Click
Dim o As New MyTestClass
Me.TextBox1.DataBindings.Add("Text", o, "Test")
End Sub

Thanks
Dave

"IbrahimMalluf" <Ib*****@malluf.com> wrote in message
news:O6**************@tk2msftngp13.phx.gbl...
Lets see the validation code in the Object Dave...
--
Ibrahim Malluf
http://www.malluf.com
==============================================
MCS Data Services Code Generator
http://64.78.34.175/mcsnet/DSCG/Announcement.aspx
==============================================

"Dave Wurtz" <da*******************@asdsoftware.com> wrote in message
news:3f******@news.splitrock.net...
All,

Not sure if I'm taking the correct approach or not, but here it is...

I have my business object with a property. I want to validate the Setting of this property with the business object. This works fine. I then create
a Form, put a TextBox control on it, add a DataBinding to the control to

the
business object's property. When the control is displayed, it sets the

text
to the property's get - perfect. When I type something in the textbox and tab off of it, it calls the Set part of the property, which validates the value and throws an exception. Where does this exception go? It doesn't seem to go anywhere - as if the internal .net code has a try...catch, but is
not doing anything with the exception.

Is this even the correct approach for control validation? I have to

have the validation in the business object and I don't want to have to re-write it again in the GUI.

Any help is appreciated!

Dave


Nov 20 '05 #7
"Dave Wurtz" <da*******************@asdsoftware.com> wrote...

Dave... I'm going to guess you took too many shortcuts.

Start off by adding a private property to MyTestClass and actually Get and
Set it (we want it to work properly.)

Then you are declaring your object in the Button_Click handler. It isn't
going to be visible outside of there right? And you are adding the binding
there too, each time you click.

So declare the instance of MyTestClass as a private property of the form,
assign the value of Test and do the binding in form_load. You shouldn't
need to be clicking the button to test it.

Tom

Public Class MyTestClass
Public Property Test() As String
Get
Return "Test"
End Get
Set(ByVal Value As String)
Throw New System.Exception("This is an exception")
End Set
End Property
End Class

Create a window with a button and a textbox. Here's my binding code:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs Handles Button1.Click
Dim o As New MyTestClass
Me.TextBox1.DataBindings.Add("Text", o, "Test")
End Sub

Nov 20 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

19 posts views Thread by Bruce Duncan | last post: by
3 posts views Thread by Student | last post: by
17 posts views Thread by stathis gotsis | last post: by
11 posts views Thread by Rik | last post: by
8 posts views Thread by Bryan | last post: by

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.