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 5 3558
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" <na***********@yahoo.co.uk> wrote in message
news:9e*************************@posting.google.co m... 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
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" <na***********@yahoo.co.uk> wrote in message
news:9e*************************@posting.google.co m... 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
Dear Nazir;
One solusion is to use HTML Control instead of Server Control and use both
"onClick" and "onServerClick" events, as I did (following code).
But i think there should be better way... anybody has idea?
Regards,
Tohid
<%@ Page Language="VB" %>
<script runat="server">
Sub Button1_Click(sender As Object, e As EventArgs)
Response.Redirect("http://www.google.com")
End Sub
</script>
<html>
<head>
<script language="JavaScript">
function OpenNew() {
window.open("http://www.yahoo.com")
}
</script>
</head>
<body>
<form runat="server">
<input id="button1" onclick="javascript :OpenNew();" type="button"
value="Button" runat="server" onserverclick="Button1_Click" />
<!-- Insert content here -->
</form>
</body>
</html>
----- Original Message -----
From: "Nazir" <na***********@yahoo.co.uk>
Newsgroups: microsoft.public.dotnet.framework.aspnet
Sent: Wednesday, October 22, 2003 1:21 PM
Subject: Redirect a page after a new window opened? 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
Dear Nazir;
One solusion is to use HTML Control instead of Server Control and use both
"onClick" and "onServerClick" events, as I did (following code).
But i think there should be better way... anybody has idea?
Regards,
Tohid
<%@ Page Language="VB" %>
<script runat="server">
Sub Button1_Click(sender As Object, e As EventArgs)
Response.Redirect("http://www.google.com")
End Sub
</script>
<html>
<head>
<script language="JavaScript">
function OpenNew() {
window.open("http://www.yahoo.com")
}
</script>
</head>
<body>
<form runat="server">
<input id="button1" onclick="javascript :OpenNew();" type="button"
value="Button" runat="server" onserverclick="Button1_Click" />
<!-- Insert content here -->
</form>
</body>
</html>
----- Original Message -----
From: "Nazir" <na***********@yahoo.co.uk>
Newsgroups: microsoft.public.dotnet.framework.aspnet
Sent: Wednesday, October 22, 2003 1:21 PM
Subject: Redirect a page after a new window opened? 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
Thanks for the replies - they led me to an answer:
I registered an onsubmit script in the code behind page,
RegisterOnSubmitStatement("valid", " if (Page_IsValid)
{window.location = '[result url]'} ")
NH
"Tohid" <To********@hotmail.com> wrote in message news:<#8*************@TK2MSFTNGP11.phx.gbl>... Dear Nazir;
One solusion is to use HTML Control instead of Server Control and use both "onClick" and "onServerClick" events, as I did (following code). But i think there should be better way... anybody has idea?
Regards, Tohid <%@ Page Language="VB" %> <script runat="server">
Sub Button1_Click(sender As Object, e As EventArgs) Response.Redirect("http://www.google.com") End Sub
</script> <html> <head> <script language="JavaScript"> function OpenNew() { window.open("http://www.yahoo.com") } </script> </head> <body> <form runat="server"> <input id="button1" onclick="javascript:OpenNew();" type="button" value="Button" runat="server" onserverclick="Button1_Click" /> <!-- Insert content here --> </form> </body> </html>
----- Original Message ----- From: "Nazir" <na***********@yahoo.co.uk> Newsgroups: microsoft.public.dotnet.framework.aspnet Sent: Wednesday, October 22, 2003 1:21 PM Subject: Redirect a page after a new window opened?
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: lukeo |
last post by:
I'm shelling out to an .asp (or htm) page from an application. I want
to show this in a window without the address bar, etc...
Is there a way I can redirect this page using javascript to a page...
|
by: Todd Lu |
last post by:
I am trying to redirect a login page to another page after validating the
username and password. I am currently trying to use javascript with the
window.open command but this leaves the...
|
by: kevinm3574 |
last post by:
So, I'm doing the following in a php script so that I can fire a
download dialogue AND redirect the page (after clicking submit in a
form). I'm doing it this way because of the problem with...
|
by: TC |
last post by:
Hello,
In ASP.Net via C#, but if someone can help me with a VB.Net example that's
fine too, I am trying to redirect to a page that is already open.
For example, when a user clicks a submit...
|
by: Nazir |
last post by:
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...
|
by: ODB |
last post by:
Okay what i need is to open af new browser windows with some link in, but i
can't get the Response.Redirect to open af new window, and when i redirect
to a new page in the same window and then hit...
|
by: news://news.microsoft.com/microsoft.public.de.germ |
last post by:
Hallo!
Ich habe ein Frameset mit 3 Frames.
Im 1. Frame wird eine ASPX-Seite geöffnet. In dieser werden einige
Steuerelemente angezeigt.
Nun soll bei bestimmten Benutzeraktivitäten eine andere...
|
by: Hitesh |
last post by:
Hi,
I am having a requirement where in user can click on a link and the download
popup appears and then user should be redirected to a congratulations page.
We didn't bother whether the...
|
by: Doug |
last post by:
In the code below, I am trying to go from one asp page to another:
For Each tripToAccept As String In tripsToAccept.Split("/"c)
dataManager.UpdateTripDetail("Accept", CInt(tripToAccept),...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: DJRhino |
last post by:
Was curious if anyone else was having this same issue or not....
I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: Aliciasmith |
last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
|
by: Teri B |
last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course.
0ne-to-many. One course many roles.
Then I created a report based on the Course form and...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM)
Please note that the UK and Europe revert to winter time on...
|
by: nia12 |
last post by:
Hi there,
I am very new to Access so apologies if any of this is obvious/not clear.
I am creating a data collection tool for health care employees to complete. It consists of a number of...
|
by: isladogs |
last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, Mike...
| |