473,831 Members | 2,306 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Validate and keep form open

I'm trying to use the ErrorProvider in order to validate
my form. This is working well except that in the event of
a failure on my modal dialog, I'd like to keep the dialog
open.

I open the dialog like this:
if (formOptions.Sh owDialog(this) == DialogResult.OK )

When the user clicks on "Save" in the form I do the
validation and regardless of success or failure in the
validation the form is hidden.

How, can I override the button click and keep the form
open?
Nov 15 '05 #1
2 7050
There is a simple solution. Just set the DialogResult Property in
your button click handler.

private void mButtonSave_Cli ck(object sender, System.EventArg s e)

{
// Perform Validation Test
bool isValid = false;

if(isValid)
{
// Set the Dialog Result of the Form You are Showing when the
validation
// Passes
this.DialogResu lt = DialogResult.OK ;
return;

}
// If the validation fails the Form will stay up.
this.DialogResu lt = DialogResult.No ne;
}
Nov 15 '05 #2
Hi Ron,

There is a simple solution. Just set the Dialogresult property from your code.

private void mButtonSave_Cli ck(object sender, System.EventArg s e)
{
// Perform Validation Test
bool isValid = false;

if(isValid)
{
// Set the Dialog Result of the Form You are Showing when the validation
// Passes
this.DialogResu lt = DialogResult.OK ;
return;
}

// If the validation fails the Form will stay up.
this.DialogResu lt = DialogResult.No ne;
}
Nov 15 '05 #3

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

Similar topics

1
2508
by: Mattia | last post by:
Hi! I would like to validate a fiels in a form, but the code I wrote doesn't seem to work: HTML: <form name="formNome" method="post" action="/index.php" onSubmit="return check_profilo_cambia( this )"> <input type="text" name="nome" value="Mattia"><br> </form>
1
2972
by: 4004 | last post by:
I would like to open a columnar form (so I can see all the details) from a datasheet form (so I can see what is there) but keep the same recordset and current record. I can do the recordset set part (stlinkcriteria) - but how do I have the new form open on the record that was current in the datasheet form? I don't want to filter to the current record when the 2nd form opens - I would like to be able to keep the whole rs and be able to...
1
1035
by: Jack Wheeler | last post by:
I have a basic form with some textboxes and several requiredfielfvalidators. On my development machine, the validation for this form works fine. On the remote server, the form posts back with no attempt at validation at all. It's as if the requiredfieldvalidators weren't even there. The kicker is, that a test form on the remote server DOES validate! Any idea as to what would keep this form from validating? Thanks, Jack Wheeler
1
1881
by: anilareddy | last post by:
I have an application like this. I need to validate the start time in 2nd row against the start row in first row. I mean The start time value entered in the second row must not b the value entered in 1st and the value entered in 3rd must not b the value entered in 1st,2nd etc.. like this. Please tell me how it can be done. I'm sending the code here. Its a html file. Just copy paste the code and run to execute it and see how it works. ...
1
4010
by: SkipNRun | last post by:
I am a novice when comes to JavaScript, AJAX. I am working on a form, which will allow users to update their contact information. In order to make the form flexible, I need to use pull down list. Depends on the pull down list selection, I use script.aculo.us to validate the user input before submit and pass the necessary data, such as contact type, contact information and ranking to a php program for updating. This form should allow multiple...
24
2114
by: Mike Hofer | last post by:
Please forgive the cross-post to multiple forums. I did it intentionally, but I *think* it was appropriate given the nature of my question. I'm working on an open source code library to help automate and clean up parameter validation code. It's almost ready to go into open beta. But one last little glitch is holding me up, and that would be the name of the factory class that serves as the entry point into the library: Validate.
3
2302
by: Jeff | last post by:
I know how to use php/mysql, but the html aspect of what Im trying to do (if its even possible this way) is what Im unsure of. I want to have a button that a user can hit to valid mysql info before submitting the full page of info. I know this doesnt work, but something like the following:
0
9793
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9642
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,...
1
10534
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
9317
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 project—planning, coding, testing, and deployment—without 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...
1
7748
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6951
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5619
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
5780
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3076
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.