
Here is the sample code for the child modal popup form. Window.showModalDialog('CSharpModalChild.aspx', '', 'status:1 resizable:1 dialogWidth:900px dialogHeight:500px dialogTop=50px dialogLeft:100px') Protected void btnMainFormSaveEvent_Click(object sender, EventArgs e)
When you press the button Save the Main Parent Form, the information entered from the child popup form will be retrieved from the ASP.NET session and will be shown in the read-only text area on the parent form.
The modal dialog will close itself and set the text you entered into the ASP.NET session state.Then you can enter general text in the modal dialog’s text area and press the save button.
first press the step #1 button to open the modal dialog form. In an earlier example I have posted the VB versions of these pages. Note that both examples are written in C#, but the VB looks quite similar. Here is the sample code for the Parent form page. Code Example for Saving Modal Popup Form Field Information The Main Page (Parent Page) Then, when the user clicks the save button on the parent form, all of the information is available to be processed. Once the information entered by the user in the modal popup form has been saved and the popup has been closed, the information entered is available through the session state or database to the parent form. The basics of using this technique involves saving your popup form’s values into the ASP.NET session, or directly to your database and then invoking the JavaScript self.close() function call from your codebehind using the ClientScriptManager.RegisterClientScriptBlock Method. Unlike the pure HTML/JavaScript method mentioned earlier, you don’t need to worry about client entered values breaking your JavaScript. You can do so using a code-behind ASP.NET button click event in combination with the ASP.NET ClientScriptManager.RegisterClientScriptBlock Method. ASP.NET/JavaScriptĪnother method that you can use to store information from your modal child dialog form is to combine your Server-Side logic with your Client Side JavaScript logic. This is a useful technique but you will need to escape and un-escape special characters that JavaScript can’t handle when you are passing client-entered values. Pure HTML/JavaScriptįor starters you can use pure HTML and JavaScript to set hidden text fields in your parent form with the information entered by a user in the child dialog form. There are two straightforward ways that you can use to handle interactions between your modal popup (child) form and its instantiating (parent) form.
ShowModalDialog – Example Code and Some Tips.
showModalDialog Opens a New Window on Submit or location.href. If you have questions about some of the code I’ve used in this article, then please take a look at my earlier articles that might help explain some of the concepts: In earlier articles I have covered some of the general functions and benefits of using the ShowModalDialog function that I will expand on this article. Login form w3schools.In this article I will go through a technique that you can use when working with a modal popup that lets you store form information from your popup to later use with your main Web form.