.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

OpenFileDialog OK/Cancel button closes form that opened it

Posted By:      Posted Date: September 20, 2010    Points: 0   Category :Windows Application

After clicking OK or Cancel from the OpenFileDialog, the calling form gets closed not allowing user to push OK on calling form to save changes.  Strange thing is, if calling form is opened modeless from main form, this does not happen.  But I do not want this form to be left open modeless.

Here's the code:

Main Form opens form to change a file path

    Private Sub AdvancedDatabaseConfigurationToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AdvancedDatabaseConfigurationToolStripMenuItem.Click

        Dim formDBPath As New frmDBPath


    End Sub
formDBPath has a button to browse to new file path which opens the OpenFileDialog
  Private Sub btnBrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBrowse.Click

    Dim openResult As DialogResult = Me.OpenFileDialog1.ShowDialog(Me)

    If openResult = Windows.Forms.DialogResult.Cancel Then Exit Sub
    Me.txtNewDBPath.Text = Me.OpenFileDialog1.FileName

  End Sub

 When I step through in the debugger, I click OK on the OpenFileDialog, it returns to btnBrowse_Click sub and sets the textbox text, then control passes back to main form sub AdvancedDatabaseConfigurationToolStripMenuI

View Complete Post

More Related Resource Links

replacing ok and cancel button of an alert message with YES an NO button in asp.net web application.


i want to replace ok and cancel button of an alert message with YES an NO button in asp.net web application.When a user will click yes the data will be saved in the database and if user clicks that will act as a reset button and do not save the data in database and the control will move with as usual to the redirect page.Any pointers will be highly appreciated.I am usin g C# language.

Infopath 2007 print view in browser enabled form with Print button


Hi i create a  print view brower enabled form in Infopath 2007 with header and footer. In Infopath works fine. Margin was ok, header and footter to. But then i try to print this browser the margin, header and footer it changes to default setting of browser ? I try also create a print button in form with VS 2008 code, but method :

this.print(); not working.

It is possible to print the "print view" in browser as the same like in Infopath 2007? Does anyone have the code how to create a print button in C# on browser enabled form?

Button in a form that does not submit


I've been trying to figure this out all afternoon but my google-fu seems to be failing me. I'm setting up a page with a fairly large form, which has one field that is going to require some kind of popup page that will allow the user to perform a lookup. At the moment I'm only prototyping the page so I'm actually only attempting to a the button up to fire an alert when the button is clicked instead of generating a lookup screen. However it seems that no matter what I do the button causes the form to submit.

I remember one of the very first ASP .NET beginner videos I ever watched went through configuring a button to perform actions without submitting, but I can't seem to figure out which one it was.

Infopath form using Visual Studio - How to bind repeating table on submit button click ?


Hello friends,

   I have created infopath form using Visual Studio 2008

Form have 3 dropdowns and one repeating table which is bound by Datasource ( List from sharepoint ).

whenever i select appropritae values from drop down, Repeating table gets bound as datasource for dropdown and repeating table are same.

I have done conditional formating for repeating table using repeating table properties.


My Question:


Now i included one submit button and i want when i click submit button it will check DropDown Values and if appropriate record matching these values found it will fill repeating table

How i achive this ? as i dont find how to bind repeating table on submit button.

Please help if anyone have answer.


Thanks and Regards,


Kapil Bhosale.




click a button to print current window form

how can i click a button to print current window form? i don't know how to set and define something? anyone give me example for my reference   thanks.

OK button click on Windows dialogue form not triggering click event

I have created an Add-In for Outlook 2003 in Visual Studio 2005. When a new message is sent and a toggle button is selected, a form that I have created will be displayed as a dialogue box, where further information can be entered. Once this information has been entered you can click the OK button and the message is sent. If you were to click the OK button with invalid data in the form, there would be a message box with an error message. This all works perfectly on my development machine but when I have packaged the Add-In and installed it on other machines it does not work. Clicking on the OK button does nothing, there is not even an error message. All the prerequsits are successfully installed and this is the only part of the Add-In that does not work. All help greatly appreciated. Thanks Nick

Creating a "Save Button" in a browser based Form

I'm not sure if I'm missing something obvious, but I need to have the funtionality of the "Save Button", which is available and works on the tool bar, available in the form...and I can't seem figure out how to do it.I've found examples, in this forum, of how to use the "Submit Button" to act as the "Save Button", which did work for me, but only when specific basic criteria was met.The criteria that I now have is that I'm initiating a workflow to automatically start when a new item is created.  My workflow then moves the form to one of a few possible different form libraries, based on the logic in my workflow.  The different form libraries are to manage different teams of people that would have access to the Form and then that team would process the form accordingly.My specific situation: 1 - User opens a new form (works) 2 - User enters data and then submits the new form (works) 3 - Workflow is initiated and the form is moved to another form library to be worked on by a select group of people (works) 4 - The form is opened and reviewed and some changes are made to the form data by the select group of people (works) 5 - The form data in the form libary is updated (works, but only if the save button is pressed in the tool bar and then manually closes t

Form Action Button to pass parameters through URL and how to fill a NewForm with them

Hi I'm trying to solve a bigger problem we have in babysteps, and I guess after days of searching and trying I simply need to ask for help. The big picture is, that we're trying to put a Form Action Button (via Sharepoint Designer 2007) above a custom DataForm DispForm.aspx which is supposed to navigate to a NewForm.aspx where the Title Field is supposed to be prefilled with a parameter from the DispForm and the user should be able to add information to the item before it is saved. I found several explanations from people on the internet, but nothing really worked. The first babystep would be to get the parameter through the button into the url of the new item.   < input type = "button" value = "Zugriff Beantragen" name = "btnFormAction0" onclick = "javascript: {ddwrt:GenFireServerEvent('__redirect={../Zugriff Beantragen 2/NewForm2.aspx?test={ItemID}')}" />   That's the code for my button. Somebody wrote that should definitely work because SharePoint is able to replace {ItemID} with the actual ID of the item. Well.... it kind of doesn't. What I get as the end of the new URL is exactly "...?test={ItemID}"   I tried with different names for the ID, I added an @ before those ... no change. I read somewhere about javascript.functionName() which should work with all parameters of the item, but

Web Form breaks after using the browser's back button

I have a web form that allows a user to put some data in a textbox and click a button to do a search on that data.  It opens up a Sql Server Reporting Services report using the data they entered on the previous page.  If they use the browser's back button to go back and enter some different criteria to search on, the buttons don't work anymore. Any ideas or suggestions on what would cause this?   Thanks! 

Customize Form button now showing up on ribbon

I used SP2010 Beta for 7 months and the Customize Form button was available on the ribbon for lists. Now, I am on the RTM, and cannot figure out how to show this button. Is it a feature? Do you have to have InfoPath 2010 installed locally? (I do have this, but just wondering). Thanks in advance.

How to cancel(disable) combobox in the time is under pressure button?

Hi I have one button and one combobox. How to do so that in time I press the button the combobox turn on be gray or freez. thanks 

Print Button +code in form

Using sharepoint 2010 and designed a simple form. How can I add the Print functionality to the ribbon from standard SP2010 NOT using Infopath? thx

Adding a Cancel Button

Hi, I have an application that performs a very big algorithm when a button is clicked. I'm trying to add a "Cancel Button" if the user wants to cancel the operation. The problem is the cancel button doesn't fire any event while the program is executing another events. Actually it seems beeing inactive. Any idea of how can I solve the problem?

Problem to open infopath form : The file cannot be opened because it is not a valid InfoPath form

Hi i have a winform app which host of infopath forms. form templates and data stores in database and when user want to open/edit an existing infopath form data, it must be extract from database, save on disk and then open it to display it in formControl. my problem is that when i open form data, after it has been extracted on disk, i got this error : InfoPath cannot open the following file: C:\Users\Hamed\Documents\Visual Studio 2008\Projects\InfopathFormTest2\InfopathFormTest2\bin\Debug\d00d73e8-cf5c-4b12-b9a6-591c4ade83aa.xml. The file cannot be opened because it is not a valid InfoPath form.  The processing instruction in the file is missing or invalid. here is my code : this._fullPath = System.IO.Path.Combine(Application.StartupPath, this._dataRow.FormID.ToString() + ".xml"); this._templatePath = System.IO.Path.Combine(Application.StartupPath, this._templateRow.TemplateID.ToString() + ".xsn");if (HelperClass.ExtractToDisc(_fullPath, ASCIIEncoding.Unicode.GetBytes(this._dataRow.FormContent))) { this.formControl1.Open(_fullPath); this.txtFormName.Text = this._dataRow.FormName; } where is my problem and how to solve this ? thanks in advancehttp://www.codeproject.com/KB/codegen/DatabaseHelper.aspx

Form Validation, BindingGroup, CommandBinding, Disabling Commit Button

Hi, I've been struggling with this for a few days and I couldn't get a clear and simple answer anywhere. Now that I've fixed the problem on my end, I figured I would share. The approach is about disabling a "Commit" button (Save/Apply/OK/whatever) whenever an error exists in the form. Basically, I have a form with several different controls (textbox, combobox, checkbox to name a few). All of them are bound to a custom object within my code, that I referenced using "RootGrid.DataContext = myObjectInstance". They also use BindingValidationRules, so the user is warned that they have wrong data in there. There's plenty of information about how to achieve this on the internet - but the real question mark is: how can I disable a button if there are errors in the form? First, go ahead and make those control validations work. For example, write a ValidationRule for a textbox to make sure it's only numbers in there, and then another ValidationRule for another textbox that ensures no digits are contained. Once again, google is full of examples on how to achieve this. Then, you need to group all of those controls into a BindingGroup. Before doing so, we will design a ValidationRule that will ensure the BindingGroup is free of validation errors:   public class ErrorFreeBindingGroup : ValidationRule { private string _errorMessage; public str

Displaying a Messagebox with Ok / Cancel button using C# in web application

 Hi all, I would like to get the user's confirmation by displaying a message box with ok cancel options, when you press ok it has to invoke a member function, otherwise other function. thanks. ssm.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend