I noticed that most people use the concept of posting to an iFrame. I used to do this with some degree of success, but you wind up with a bunch of extra pages in your app - 1 to be the modal window with just an iFrame on it and the other page to be the form post target which handles data changes, etc.
My suggestion would be to create a script that runs each time the page is opened as a modal window which would assign a name to itself (the current window).
Expand|Select|Wrap|Line Numbers
- ...
- </head>
- <body>
- <script language=javascript type="text/javascript">
- window.name = "MyModalPopup";
- </script>
- <form ...
Expand|Select|Wrap|Line Numbers
- ...
- <form id="form1" runat="server" target="MyModalPopup">
- ...
Handle the Cancel routine:
Expand|Select|Wrap|Line Numbers
- Protected Sub btnCancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCancel.Click
- Response.Write("<SCRIPT language=javascript>window.close();</SCRIPT>")
- End Sub
Expand|Select|Wrap|Line Numbers
- Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click
- 'example call to a function returning boolean value
- If UpdateDB() Then
- 'this is line below is optional depending on if you want to close
- 'the window automatically or not.
- Response.Write("<SCRIPT language=javascript>window.close();</SCRIPT>")
- Else
- 'write some sort of error message or js alert to the page notifying
- 'the user of the updatedb error
- End If
- End Sub