473,666 Members | 2,575 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 formCustomerInp ut.Name).

Thanks for any thoughts on this
Cheers
Ant

Oct 31 '06 #1
3 3059
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*@discussion s.microsoft.com wrote in message
news:D3******** *************** ***********@mic rosoft.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 formCustomerInp ut.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*@discussion s.microsoft.com wrote in message
news:D3******** *************** ***********@mic rosoft.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 formCustomerInp ut.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 formCustomerInp ut.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
1712
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 calling form? For example, say off of my main form I launch a modal dialog box that gets the username and password what is the best way of passing that data back? The info has to go into an object eventually so I can
2
3869
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 window. But I want modal dialog window, any ideas?? <form action="page2.asp" method="post" target="_blank"> <input type="text" name="username"> <input type="submit" name="submit"> </form>
136
9307
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 code was littered with document.all and eval, for example, and I wanted to create a practical list of best practices that they could easily put to use. The above URL is version 1.0 (draft) that resulted. IMO, it is not a replacement for the FAQ,...
3
5396
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 javascript to let him pick a value for the field from a popup modal window. <td><a href="javascript:GetNet()"> <img src="”> </a>VPN Network:</td> <% if (XYZ !=""){%> <td><asp:TextBox id="txtXYZ" runat="server" Text='<%#...
1
8065
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 carries the task of the initializing the scanner. It looks like this event is not called after the creation of one of the forms. Let me describe shortly the sequence of form creation. The app first call a browsing form by using ShowDialog()....
1
2819
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 enter input. I need to take this user input and put it back into the database. What would be the best method to do this. I can't use a normal post because the name of the text box is the same for each table row. I've heard that posting the...
10
4834
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 mouse-events do not fire. What events on Form2 fire? I could open Form2 modelessly, then process from within Form1 mouse events. Is there any other way?
1
2623
by: magix | last post by:
Hi, My popup window (Modal) target is not working. Page1.asp ======== I have javascript: function PopNewWin(url) {
1
49872
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 get anything to happen. Below is the code. Thanks in advance. jQuery: jQuery(document).ready(function() { jQuery("a").click(function() { jQuery("#dialog").dialog({ modal: true,
0
8362
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8878
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8785
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8560
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8644
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7389
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4200
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2776
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.