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="NGExa mple"%>
<html lang="en">
<body>
<h1>Form Window</h1>
<form id="NGExample" method="post" target="_blank" runat="server">
<asp:Validation Summary
id="valSummary "
runat="server"
HeaderText="Sor ry, there was a problem with your details:"
ShowSummary="tr ue" DisplayMode="Li st" />
<p>Required field - </p>
<table border=0>
<tr><td width="120">Inp ut name
<asp:RequiredFi eldValidator id="valRequired 1"
runat="server"
ControlToValida te="txtName"
ErrorMessage="* You must enter a name"
Display="static ">*</asp:RequiredFie ldValidator>:
</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="createNewWi ndow"
Text="Submit" runat="server">
</asp:Button>
</td></tr>
</table>
</form>
</body>
</html>
########## aspx.vb
Public Class NGExample
Inherits System.Web.UI.P age
Protected txtName As System.Web.UI.W ebControls.Text Box
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) 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 3595
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.RegisterSt artupScript() 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.goog le.com... 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="NGExa mple"%>
<html lang="en"> <body> <h1>Form Window</h1> <form id="NGExample" method="post" target="_blank" runat="server"> <asp:Validation Summary id="valSummary " runat="server" HeaderText="Sor ry, there was a problem with your details:" ShowSummary="tr ue" DisplayMode="Li st" />
<p>Required field - </p> <table border=0> <tr><td width="120">Inp ut name <asp:RequiredFi eldValidator id="valRequired 1" runat="server" ControlToValida te="txtName" ErrorMessage="* You must enter a name" Display="static ">*</asp:RequiredFie ldValidator>: </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="createNewWi ndow" Text="Submit" runat="server"> </asp:Button> </td></tr> </table> </form> </body> </html> ########## aspx.vb
Public Class NGExample Inherits System.Web.UI.P age Protected txtName As System.Web.UI.W ebControls.Text Box
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArg s) 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.RegisterSt artupScript() 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.goog le.com... 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="NGExa mple"%>
<html lang="en"> <body> <h1>Form Window</h1> <form id="NGExample" method="post" target="_blank" runat="server"> <asp:Validation Summary id="valSummary " runat="server" HeaderText="Sor ry, there was a problem with your details:" ShowSummary="tr ue" DisplayMode="Li st" />
<p>Required field - </p> <table border=0> <tr><td width="120">Inp ut name <asp:RequiredFi eldValidator id="valRequired 1" runat="server" ControlToValida te="txtName" ErrorMessage="* You must enter a name" Display="static ">*</asp:RequiredFie ldValidator>: </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="createNewWi ndow" Text="Submit" runat="server"> </asp:Button> </td></tr> </table> </form> </body> </html> ########## aspx.vb
Public Class NGExample Inherits System.Web.UI.P age Protected txtName As System.Web.UI.W ebControls.Text Box
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArg s) 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 "onServerCl ick" 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(s ender As Object, e As EventArgs)
Response.Redire ct("http://www.google.com" )
End Sub
</script>
<html>
<head>
<script language="JavaS cript">
function OpenNew() {
window.open("ht tp://www.yahoo.com")
}
</script>
</head>
<body>
<form runat="server">
<input id="button1" onclick="JavaSc ript: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.publi c.dotnet.framew ork.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="NGExa mple"%>
<html lang="en"> <body> <h1>Form Window</h1> <form id="NGExample" method="post" target="_blank" runat="server"> <asp:Validation Summary id="valSummary " runat="server" HeaderText="Sor ry, there was a problem with your details:" ShowSummary="tr ue" DisplayMode="Li st" />
<p>Required field - </p> <table border=0> <tr><td width="120">Inp ut name <asp:RequiredFi eldValidator id="valRequired 1" runat="server" ControlToValida te="txtName" ErrorMessage="* You must enter a name" Display="static ">*</asp:RequiredFie ldValidator>: </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="createNewWi ndow" Text="Submit" runat="server"> </asp:Button> </td></tr> </table> </form> </body> </html> ########## aspx.vb
Public Class NGExample Inherits System.Web.UI.P age Protected txtName As System.Web.UI.W ebControls.Text Box
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArg s) 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 "onServerCl ick" 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(s ender As Object, e As EventArgs)
Response.Redire ct("http://www.google.com" )
End Sub
</script>
<html>
<head>
<script language="JavaS cript">
function OpenNew() {
window.open("ht tp://www.yahoo.com")
}
</script>
</head>
<body>
<form runat="server">
<input id="button1" onclick="JavaSc ript: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.publi c.dotnet.framew ork.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="NGExa mple"%>
<html lang="en"> <body> <h1>Form Window</h1> <form id="NGExample" method="post" target="_blank" runat="server"> <asp:Validation Summary id="valSummary " runat="server" HeaderText="Sor ry, there was a problem with your details:" ShowSummary="tr ue" DisplayMode="Li st" />
<p>Required field - </p> <table border=0> <tr><td width="120">Inp ut name <asp:RequiredFi eldValidator id="valRequired 1" runat="server" ControlToValida te="txtName" ErrorMessage="* You must enter a name" Display="static ">*</asp:RequiredFie ldValidator>: </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="createNewWi ndow" Text="Submit" runat="server"> </asp:Button> </td></tr> </table> </form> </body> </html> ########## aspx.vb
Public Class NGExample Inherits System.Web.UI.P age Protected txtName As System.Web.UI.W ebControls.Text Box
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArg s) 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,
RegisterOnSubmi tStatement("val id", " if (Page_IsValid)
{window.locatio n = '[result url]'} ")
NH
"Tohid" <To********@hot mail.com> wrote in message news:<#8******* ******@TK2MSFTN GP11.phx.gbl>.. . Dear Nazir;
One solusion is to use HTML Control instead of Server Control and use both "onClick" and "onServerCl ick" 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(s ender As Object, e As EventArgs) Response.Redire ct("http://www.google.com" ) End Sub
</script> <html> <head> <script language="JavaS cript"> function OpenNew() { window.open("ht tp://www.yahoo.com") } </script> </head> <body> <form runat="server"> <input id="button1" onclick="JavaSc ript: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.publi c.dotnet.framew ork.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="NGExa mple"%>
<html lang="en"> <body> <h1>Form Window</h1> <form id="NGExample" method="post" target="_blank" runat="server"> <asp:Validation Summary id="valSummary " runat="server" HeaderText="Sor ry, there was a problem with your details:" ShowSummary="tr ue" DisplayMode="Li st" />
<p>Required field - </p> <table border=0> <tr><td width="120">Inp ut name <asp:RequiredFi eldValidator id="valRequired 1" runat="server" ControlToValida te="txtName" ErrorMessage="* You must enter a name" Display="static ">*</asp:RequiredFie ldValidator>: </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="createNewWi ndow" Text="Submit" runat="server"> </asp:Button> </td></tr> </table> </form> </body> </html> ########## aspx.vb
Public Class NGExample Inherits System.Web.UI.P age Protected txtName As System.Web.UI.W ebControls.Text Box
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArg s) 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
where I can set the window height, statusbar=no, etc?
Thanks,
-Luke
|
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 window.opener to stay open. is
there a good way to redirect to a new form in .net 2003 without having the
menubar present and the parent form to close?
Thanks,
Todd
|
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 headers and
such and server-side vs client-side issues:
$dir = "somedir";
$file = "somefile";
print("
<script language=\"JavaScript\">
|
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 button on the main page, a new
window is opened that displays the material. The user then goes back to the
main page and makes changes and clicks the submit button again.
Rather than opening a new window again, I want the user to be redirected to
|
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 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).
| |
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 back, i have some olde
invalid data in my window. and i realy need to open af new browser ?
Thanks ODB
|
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 ASPX-Seite geöffnet
werden, und zwar in einem der beiden anderen Frames. Mein Problem ist, dass
die Seite, die geöffnet werden soll, manchmal im 2. und manchmal im 3. Frame
angezeigt werden soll (je nach Benutzeraktivität).
|
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 download is successful or not but as soon as
user clicks on the download link the popup appears, and then the user should
be directed to the congratulations page.
I have written the standard code to download the file but after that i am
|
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),
Hiduser.Value)
Next
Response.Redirect("TripAcceptReject.aspx", False)
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |