473,394 Members | 1,865 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,394 software developers and data experts.

Best practice - Using modal input form

Ant
Hi,

I'm using a modal dialog box to input data. I have created properties on the
dialog form to capture the data so that it might be read from the main form
via the dialog form. This approach encapsulates the data & I can implement
the business logic in the dialog form.

This leaves me with the quiestion. There is no Class representing the data
I'm capturing, (say, it's a customer) apart from the dialog form class. The
form now represents the customer.

Are there problems with this approach? Should I create a Class solely for
the purpose of holding the customer data & pass that to the main form via
say, a delegate, or is it ok to hold data in the forms properties.

(e.g formCustomerInput.Name).

Thanks for any thoughts on this
Cheers
Ant

Oct 31 '06 #1
3 3033
Hi Ant,

I say go ahead and make a Customer class. After all, you'll probably be able
to use it in other places as well.

You don't need a delegate to return the Customer to the main Form, however. I
think a public property on the dialog Form will do just fine. If the user
cancels the dialog (usually by clicking the close button or a custom Cancel
button) then just return null.

--
Dave Sexton

"Ant" <An*@discussions.microsoft.comwrote in message
news:D3**********************************@microsof t.com...
Hi,

I'm using a modal dialog box to input data. I have created properties on the
dialog form to capture the data so that it might be read from the main form
via the dialog form. This approach encapsulates the data & I can implement
the business logic in the dialog form.

This leaves me with the quiestion. There is no Class representing the data
I'm capturing, (say, it's a customer) apart from the dialog form class. The
form now represents the customer.

Are there problems with this approach? Should I create a Class solely for
the purpose of holding the customer data & pass that to the main form via
say, a delegate, or is it ok to hold data in the forms properties.

(e.g formCustomerInput.Name).

Thanks for any thoughts on this
Cheers
Ant

Oct 31 '06 #2
Ant
Hi Dave,

Thanks very much for the advice. that sounds like the best approach to me as
well.

many thanks.

Ant

"Dave Sexton" wrote:
Hi Ant,

I say go ahead and make a Customer class. After all, you'll probably be able
to use it in other places as well.

You don't need a delegate to return the Customer to the main Form, however. I
think a public property on the dialog Form will do just fine. If the user
cancels the dialog (usually by clicking the close button or a custom Cancel
button) then just return null.

--
Dave Sexton

"Ant" <An*@discussions.microsoft.comwrote in message
news:D3**********************************@microsof t.com...
Hi,

I'm using a modal dialog box to input data. I have created properties on the
dialog form to capture the data so that it might be read from the main form
via the dialog form. This approach encapsulates the data & I can implement
the business logic in the dialog form.

This leaves me with the quiestion. There is no Class representing the data
I'm capturing, (say, it's a customer) apart from the dialog form class. The
form now represents the customer.

Are there problems with this approach? Should I create a Class solely for
the purpose of holding the customer data & pass that to the main form via
say, a delegate, or is it ok to hold data in the forms properties.

(e.g formCustomerInput.Name).

Thanks for any thoughts on this
Cheers
Ant


Oct 31 '06 #3
Hi Ant,
it is always best practise to keep the UI seperate from data wherever
possible, as Dave mentioned by creating a customer data type you can then
pass that data to other forms or other parts of your code, rather than ending
up with many unconnected variables. Also by separating your UI from your
business objects as much as possible will make it easier to refactor your UI
without causing you to have to refactor your underlying logic.

Another bonus if you are into testing your code is that testing your
underlying logic through a UI is hard, by separating your logic form the UI
you can easily unit test your business objects i.e. NUnit / Visual Studio etc
without a UI which is a lot easier.
Mark.
--
http://www.markdawson.org
"Ant" wrote:
Hi,

I'm using a modal dialog box to input data. I have created properties on the
dialog form to capture the data so that it might be read from the main form
via the dialog form. This approach encapsulates the data & I can implement
the business logic in the dialog form.

This leaves me with the quiestion. There is no Class representing the data
I'm capturing, (say, it's a customer) apart from the dialog form class. The
form now represents the customer.

Are there problems with this approach? Should I create a Class solely for
the purpose of holding the customer data & pass that to the main form via
say, a delegate, or is it ok to hold data in the forms properties.

(e.g formCustomerInput.Name).

Thanks for any thoughts on this
Cheers
Ant
Oct 31 '06 #4

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

Similar topics

3
by: RubiconXing | last post by:
Hi All Beginner question - please be patient with me :-) I am new to c#. If one creates a child modal (and also non-modal) form what is the best way of returning the collected data back to the...
2
by: Matt | last post by:
I want to know how to submit the form data to a modal dialog window? The following is page1.asp, and when the user clicks submit button, it will post the form data to page2.asp by opening a new...
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
3
by: cindy | last post by:
I have a web form “Form1” with a panel. Inside the panel is a datalist. One of the items displays the field value “xyz” from the dataset. If the field is null the user clicks on a...
1
by: SammyBar | last post by:
Hi all, I'm having troubles with a Symbol 9000 device (Compact Framework v 1.1) when activating the barcode scanner from a window. The problem is related to the Activated event of the form which...
1
by: Muchach | last post by:
Hello, Ok so what I've got going on is a form that is populated by pulling info from database then using php do{} to create elements in form. I have a text box in each table row for the user to...
10
by: bern11 | last post by:
If Form1 opens Form2 modally, how do I capture clicks on Form1 when Form2 is open? I want to click on Form1 and read the mouse co-ordinates into Form2. Since Form2 is open modally, Form1...
1
by: magix | last post by:
Hi, My popup window (Modal) target is not working. Page1.asp ======== I have javascript: function PopNewWin(url) {
1
by: mikeh3275 | last post by:
I'm new to developing in jQuery, so I'm probably doing this wrong. I'm loading a form into a modal dialog box and I'm trying to assign a click event to the button in the form, but I can't seem to...
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
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.