473,666 Members | 2,480 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to open a new window in the server side?

Hi, experts,
On a button click, I need to save some data to the session object. Then open
a new window. The new window will use the session data saved in the first
window. I don't want use to click two buttons, one to save the session data
and the other one to trigger the java script to open the new window. Your
advice is highly appreciated.

Jie
Nov 17 '05 #1
8 2519
In your button click Event Handler, add the data to the Session. Then add a
JavaScript to the Page using RegisterStartup Script() to open a window
containing the second page. The second Page can then grab the Session data.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Neither a follower nor a lender be.

"J Gao" <ji*****@tequil asoftware.com> wrote in message
news:uu******** ******@TK2MSFTN GP12.phx.gbl...
Hi, experts,
On a button click, I need to save some data to the session object. Then open a new window. The new window will use the session data saved in the first
window. I don't want use to click two buttons, one to save the session data and the other one to trigger the java script to open the new window. Your
advice is highly appreciated.

Jie

Nov 17 '05 #2
J Gao,

I would use the body tag as a server control. Your page would be posted back
by the button click as normal, the session would be saved, and then you
would add javascript to open your window to the body tag's attribute
collection's onload event. This way the window will open as soon as the page
is reloaded on the client.

I have example code for how to do this on my web site,
www.aboutfortunate.com, in the code library. Search for "use body tag as
server control".

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"J Gao" <ji*****@tequil asoftware.com> wrote in message
news:uu******** ******@TK2MSFTN GP12.phx.gbl...
Hi, experts,
On a button click, I need to save some data to the session object. Then open a new window. The new window will use the session data saved in the first
window. I don't want use to click two buttons, one to save the session data and the other one to trigger the java script to open the new window. Your
advice is highly appreciated.

Jie

Nov 17 '05 #3
It does not work because it cannot guarantee that which event occurs first.
I am trying to use S. Justin Gengo's suggestion. Thanks
"Kevin Spencer" <ke***@takempis .com> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
In your button click Event Handler, add the data to the Session. Then add a JavaScript to the Page using RegisterStartup Script() to open a window
containing the second page. The second Page can then grab the Session data.
--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
http://www.takempis.com
Neither a follower nor a lender be.

"J Gao" <ji*****@tequil asoftware.com> wrote in message
news:uu******** ******@TK2MSFTN GP12.phx.gbl...
Hi, experts,
On a button click, I need to save some data to the session object. Then

open
a new window. The new window will use the session data saved in the first window. I don't want use to click two buttons, one to save the session

data
and the other one to trigger the java script to open the new window. Your advice is highly appreciated.

Jie


Nov 17 '05 #4
Thanks.
But even if I add
<body id="body" runat="server"> , I cannot see the body object. Can you tell
me where to add:
Body.Attributes .Add("onLoad", "javascript:ale rt('The username or password
entered was not valid.');")

"S. Justin Gengo" <sj*****@aboutf ortunate.com> wrote in message
news:u5******** ******@TK2MSFTN GP12.phx.gbl...
J Gao,

I would use the body tag as a server control. Your page would be posted back by the button click as normal, the session would be saved, and then you
would add javascript to open your window to the body tag's attribute
collection's onload event. This way the window will open as soon as the page is reloaded on the client.

I have example code for how to do this on my web site,
www.aboutfortunate.com, in the code library. Search for "use body tag as
server control".

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"J Gao" <ji*****@tequil asoftware.com> wrote in message
news:uu******** ******@TK2MSFTN GP12.phx.gbl...
Hi, experts,
On a button click, I need to save some data to the session object. Then

open
a new window. The new window will use the session data saved in the first window. I don't want use to click two buttons, one to save the session

data
and the other one to trigger the java script to open the new window. Your advice is highly appreciated.

Jie


Nov 17 '05 #5
J Gao,

In your code behind page you must also declare the new body tag. Did you
look at the sample?

'---First in the html view of your web form make the body tag into a server
control.
' To do so, give it an id and a runat="server" attribute.
<body id="body" runat="server">
*************** ***************
****Here's the part you're missing.****
*************** ***************

'---Next declare the body object in your code behind page.
Protected Body As System.Web.UI.H tmlControls.Htm lGenericControl

'---Now when you want to pop up a javascript alert
' just add it to the body tag.
Body.Attributes .Add("onLoad", "javascript:ale rt('The username or password
entered was not valid.');")
Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"J Gao" <ji*****@tequil asoftware.com> wrote in message
news:eH******** ******@TK2MSFTN GP10.phx.gbl...
Thanks.
But even if I add
<body id="body" runat="server"> , I cannot see the body object. Can you tell me where to add:
Body.Attributes .Add("onLoad", "javascript:ale rt('The username or password
entered was not valid.');")

"S. Justin Gengo" <sj*****@aboutf ortunate.com> wrote in message
news:u5******** ******@TK2MSFTN GP12.phx.gbl...
J Gao,

I would use the body tag as a server control. Your page would be posted

back
by the button click as normal, the session would be saved, and then you
would add javascript to open your window to the body tag's attribute
collection's onload event. This way the window will open as soon as the

page
is reloaded on the client.

I have example code for how to do this on my web site,
www.aboutfortunate.com, in the code library. Search for "use body tag as
server control".

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"J Gao" <ji*****@tequil asoftware.com> wrote in message
news:uu******** ******@TK2MSFTN GP12.phx.gbl...
Hi, experts,
On a button click, I need to save some data to the session object.
Then
open
a new window. The new window will use the session data saved in the

first window. I don't want use to click two buttons, one to save the session

data
and the other one to trigger the java script to open the new window. Your advice is highly appreciated.

Jie



Nov 17 '05 #6
Thanks Gengo. I forgot to define the body in the code behind page.

"S. Justin Gengo" <sj*****@aboutf ortunate.com> wrote in message
news:u5******** ******@TK2MSFTN GP12.phx.gbl...
J Gao,

I would use the body tag as a server control. Your page would be posted back by the button click as normal, the session would be saved, and then you
would add javascript to open your window to the body tag's attribute
collection's onload event. This way the window will open as soon as the page is reloaded on the client.

I have example code for how to do this on my web site,
www.aboutfortunate.com, in the code library. Search for "use body tag as
server control".

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"J Gao" <ji*****@tequil asoftware.com> wrote in message
news:uu******** ******@TK2MSFTN GP12.phx.gbl...
Hi, experts,
On a button click, I need to save some data to the session object. Then

open
a new window. The new window will use the session data saved in the first window. I don't want use to click two buttons, one to save the session

data
and the other one to trigger the java script to open the new window. Your advice is highly appreciated.

Jie


Nov 17 '05 #7
Great!

I'm glad it worked for you. I re-read my post after your question about what
you were missing and I thought my question "Did you look at the sample?"
might have sounded a little strong. If it did I apologize.

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"J Gao" <ji*****@tequil asoftware.com> wrote in message
news:e2******** ******@TK2MSFTN GP10.phx.gbl...
Great. It works. Thanks.

jie

"S. Justin Gengo" <sj*****@aboutf ortunate.com> wrote in message
news:u5******** ******@TK2MSFTN GP12.phx.gbl...
J Gao,

I would use the body tag as a server control. Your page would be posted

back
by the button click as normal, the session would be saved, and then you
would add javascript to open your window to the body tag's attribute
collection's onload event. This way the window will open as soon as the

page
is reloaded on the client.

I have example code for how to do this on my web site,
www.aboutfortunate.com, in the code library. Search for "use body tag as
server control".

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"J Gao" <ji*****@tequil asoftware.com> wrote in message
news:uu******** ******@TK2MSFTN GP12.phx.gbl...
Hi, experts,
On a button click, I need to save some data to the session object.
Then
open
a new window. The new window will use the session data saved in the

first window. I don't want use to click two buttons, one to save the session

data
and the other one to trigger the java script to open the new window. Your advice is highly appreciated.

Jie



Nov 17 '05 #8
Hi, Kevin,
I am sorry I missed the RegisterStartup Script method you suggest. But can
you show me the sample codes that I can register the script and trigger it
right away? I would also like to try it. Thank

Jie
"Kevin Spencer" <ke***@takempis .com> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
In your button click Event Handler, add the data to the Session. Then add a JavaScript to the Page using RegisterStartup Script() to open a window
containing the second page. The second Page can then grab the Session data.
--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
http://www.takempis.com
Neither a follower nor a lender be.

"J Gao" <ji*****@tequil asoftware.com> wrote in message
news:uu******** ******@TK2MSFTN GP12.phx.gbl...
Hi, experts,
On a button click, I need to save some data to the session object. Then

open
a new window. The new window will use the session data saved in the first window. I don't want use to click two buttons, one to save the session

data
and the other one to trigger the java script to open the new window. Your advice is highly appreciated.

Jie


Nov 17 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1623
by: Grey | last post by:
I know I need to use client side script to open new window, window.open("URL"). However, the URL in the function is dinamically generated by server side. How can I open window in client side, but specify the URL in server side.??? Million thanks -- Best Regards,
8
4354
by: Dan | last post by:
hello all, is there a way to open a new window without javascript and a href=_blank? i need to connect a button click with some lines of code and then, a new window shall get opened. but i didn't find a way to opüen a new window as result of a buttonm click. thanks for help, dan
5
8323
by: David | last post by:
Hi I don't want to use javascript to open a new window because I want to use server side code which gives me more control. I think I can not use response.redirect to open a new window and keep the current window. Is there any way to do it? Thank you! David
6
21400
by: shil | last post by:
I have a server side button that needs to do some preperation and afterwards, if everything goes well, open a new browser with a specific url. I know how to execute javascript from a server side control, adding the javascript to the attributes. I need to open the browser window AFTER the code behind event is finished. For example I have two text boxes on the form, whose values I want to send as parameters to the URL that I want to...
6
1837
by: Charlie Garrett-Jones | last post by:
i have a server side generated web application that provides parameter forms and always opens the associated reports in a new browser window. the code that controls the opening of the new browser window is simply html target='_blank'. but now there is some business rules that may be checked server side only. so if the data provided fails, i want the same target window as the parameter form and if it passes i want a new window. can anyone...
4
443
by: Guy Cohen | last post by:
Hi all How do I show an existing aspx page to the user? I need an equivalent command to java's window.open in ASP.NET TIA Guy
13
3543
by: Bob Jones | last post by:
Here is my situation: I have an aspx file stored in a resource file. All of the C# code is written inline via <script runat="server"tags. Let's call this page B. I also have page A that contains some javascript code that calls window.open. I pass the resource url of page B to Page A's window.open call. Page B is then loaded and executed but none of the server-side code is rendered. If I view the source of the page, the code (and page...
6
12072
by: bushi | last post by:
hi everyone! i have diplayed my hyperlinks in a iframe.when i redirect to next page.the next page also open in the same frame,but i want to open a new browser window,when i click on the link.actually i 'm using link button control to diplay the hyperlinks.i cant use java script "window.open()".i need some server side code behind the linkbutton,if any one knows plz rply soon.
2
8476
by: H. Rodriguez | last post by:
Hello, I would like to be able to open a new IE window on the client side and display a PDF document in the new window. Many tutorial sites that I have checked suggest opening a new IE window using client-side JavaScript and the window.open() function. I suspect this is not the desired way as I would like to output a PDF report from a byte array to the HTTP output stream to this new window. Any ideas?
0
8878
Oralloy
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...
1
8560
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8644
tracyyun
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...
0
7389
agi2029
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...
1
6200
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5671
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4200
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...
1
2776
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2012
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.