The problem is that your CodeBehind is being run in the instance of your
class that runs in the new window. You need to use
Page.RegisterStartupScript() to generate a JavaScript that uses the
window.open() method to open the new window, and then redirects to the URL
you specify.
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.
"Nazir" <nazirhaji2004@yahoo.co.uk> wrote in message
news:9e67634.0310220151.6d71aa49@posting.google.co m...[color=blue]
> I am trying to do something pretty simple - but can't see how it can
> be done in ASP.NET.
>
> I have an aspx web page with a form which opens up a new window. The
> web page uses code behind to build the new window. There is simple
> validation on the form.
>
> However, after the form page validates and opens the new window, I
> want it to redirect to another page (or stop displaying the form).
>
> I've tried adding code to the aspx.vb page to handle this, but it only
> affects the new window, not the window with the form on. If I try and
> do the redirection before IsPostBack, then it always redirects.
>
> I've tried adding code to the forms OnSubmit javascript event in the
> aspx page, but then it interferes with validation - and bypasses it.
>
> Here is an example of what I'm trying to do:
>
> ####### aspx page
>
> <%@ Page Language="vb" Src="NGExample.aspx.vb" Inherits="NGExample"%>
>
> <html lang="en">
> <body>
> <h1>Form Window</h1>
> <form id="NGExample" method="post" target="_blank" runat="server">
> <asp:ValidationSummary
> id="valSummary"
> runat="server"
> HeaderText="Sorry, there was a problem with your details:"
> ShowSummary="true" DisplayMode="List" />
>
> <p>Required field - </p>
> <table border=0>
> <tr><td width="120">Input name
> <asp:RequiredFieldValidator id="valRequired1"
> runat="server"
> ControlToValidate="txtName"
> ErrorMessage="* You must enter a name"
> Display="static">*</asp:RequiredFieldValidator>:
> </td><td>
> <asp:TextBox id="txtName"
> Text="The Name"
> maxLength="100"
> width="275px"
> runat="server" /></td></tr>
> </td></tr>
> <tr><td colspan="2" align="right">
> <asp:Button id="createNewWindow"
> Text="Submit" runat="server">
> </asp:Button>
> </td></tr>
> </table>
> </form>
> </body>
> </html>
>
>
>
> ########## aspx.vb
>
>
> Public Class NGExample
> Inherits System.Web.UI.Page
> Protected txtName As System.Web.UI.WebControls.TextBox
>
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
>
> If IsPostBack Then
> Response.Write("<h1>New Window</h1>")
> Response.Write("Form Field: " & txtName.Text)
> Response.End()
>
> End If
> End Sub
>
> End Class
>
> Any help much apprecaited.
>
> NH[/color]