473,385 Members | 1,341 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,385 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 1224
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: Bruce Duncan | last post by:
I know this isn't a php group but I was wondering if my problem is with my javascript in my php code. I'm debugging someone else's code and I can't figure out why this form won't submit. This...
7
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title>...
4
by: John Boy | last post by:
Hi, Can anyone help. This is really doing my nut in. 3 years ASP exp. and now doing .DOT which is a step in the wrong direction. Basically I am left with the code of a guy who has left. When I...
3
by: Student | last post by:
Good evening, I create a three tier ASP.NET web application. How can I validate the form input data in the Business Logic Layer? Can anyone give me an example?
12
by: cmay | last post by:
Is there any way to databind the properties of a business object, like an Employee, to fields in a form in asp.net 2.0? cmay
17
by: stathis gotsis | last post by:
Hello everyone, I am tying to come up with an elegant way to process some input data that come from a form. When the user hits the 'Submit' button, i want the form to appear again with the...
11
by: Rik | last post by:
Hello guys, now that I'm that I'm working on my first major 'open' forms (with uncontrolled users I mean, not a secure backend-interface), I'd like to add a lot of possibilities to check wether...
10
by: gweasel | last post by:
What is the best way to apply a Validation Rule - or rather, where is the best place to put it? Is there an advantage to putting it on the field in the table vs setting the validation rule on the...
8
by: Bryan | last post by:
I want my business objects to be able to do this: class Person(base): def __init__(self): self.name = None @base.validator def validate_name(self): if not self.name: return
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.