473,898 Members | 2,969 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to use an asp:button to create a new browser window and output contents to new window

Hi all, as you can see from the subject, I'm try to use an asp:button to create a new browser window and output contents to new window

But default if I do the
Response.Write( "..."

The output gets sent directly to the window or frame that the button was contained in - if I was using regular anchor links I could just specify the target - i.e.
<a href="http://...." target="nameNot InCurrentFrames et">something </a

Thanks
Novice
Nov 18 '05 #1
2 2113
You can't do it from service side. Use client-side javascript calls
showModalDialog (...) or showModalessDia log(...)

Eliyahu

"Novice" <6tc1ATqlinkDOT queensuDOTca> wrote in message
news:C4******** *************** ***********@mic rosoft.com...
Hi all, as you can see from the subject, I'm try to use an asp:button to create a new browser window and output contents to new window.
But default if I do the:
Response.Write( "...")

The output gets sent directly to the window or frame that the button was contained in - if I was using regular anchor links I could just specify the
target - i.e.: <a href="http://...." target="nameNot InCurrentFrames et">something </a>

Thanks,
Novice

Nov 18 '05 #2
Indeed you have to do use client-side code, but you actually can generate that code from server-side, al you have to do is append this code to Page.Load event handler of your ASP.NET web form.

What I do in this code is to generate the actual client side script line by line using a StringBuilder for concatenation, then I have all the script code rendered in the client HTML (immediately below the opening tag of the Page object’s <form runat=”server ”> ) when the page loads using the RegisterClientS criptBlock.

Then, using the button's Attributes collection, I map the onclick client event of the ASP.NET button to the name of the script I previously generated.

This will cause you ASP.NET button to respond to the onclick client-side event by opening a new browser window, you can customize the new browser window, in my case i did it like a popup, so that I can append some parameters to the query string.

Hope this helps,
Alan Ferrandiz
MCT;MCDBA,MCSD for .NET
MSF Practitioner

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load

Dim oStringBuilder As New System.Text.Str ingBuilder()
oStringBuilder. Append("<SCRIPT language=""java script"">")
oStringBuilder. Append(vbNewLin e)
oStringBuilder. Append(" <!--")
oStringBuilder. Append(vbNewLin e)
oStringBuilder. Append(" function popup(url) {")
oStringBuilder. Append(vbNewLin e)
oStringBuilder. Append(" newwindow = window.open(url ,'name','height =300,width=450, scrollbars=no') ;")
oStringBuilder. Append(vbNewLin e)
oStringBuilder. Append(" if (window.focus) {newwindow.focu s()}")
oStringBuilder. Append(vbNewLin e)
oStringBuilder. Append(" return false;")
oStringBuilder. Append(vbNewLin e)
oStringBuilder. Append(" }")
oStringBuilder. Append(vbNewLin e)
oStringBuilder. Append(" //-->")
oStringBuilder. Append(vbNewLin e)
oStringBuilder. Append("</SCRIPT>")

Page.RegisterCl ientScriptBlock ("popup", oStringBuilder. ToString)

Button1.Attribu tes.Add("onClic k", "return popup('popup.as px?value=someva lue');")

End Sub

"Novice" <6tc1ATqlinkDOT queensuDOTca> escribió en el mensaje news:C4******** *************** ***********@mic rosoft.com...
Hi all, as you can see from the subject, I'm try to use an asp:button to create a new browser window and output contents to new window.

But default if I do the:
Response.Write( "...")

The output gets sent directly to the window or frame that the button was contained in - if I was using regular anchor links I could just specify the target - i.e.:
<a href="http://...." target="nameNot InCurrentFrames et">something </a>

Thanks,
Novice


Nov 18 '05 #3

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

Similar topics

1
2187
by: RSB | last post by:
Hi Every one, Having tuff time to make this work .. i want to have a button and on my form say Delete button. So once i click on it i want to confirm "Are you sure?" on the Client Side and if client select "Cancel" then i want to ignore the action and if "OK" selected then i want to Execute a Server side Event or Procedure. Now what is happening here is for "Delete1" button (in my code) even if Client Select Cancel it is still...
1
238
by: Novice | last post by:
Hi all, as you can see from the subject, I'm try to use an asp:button to create a new browser window and output contents to new window But default if I do the Response.Write("..." The output gets sent directly to the window or frame that the button was contained in - if I was using regular anchor links I could just specify the target - i.e. <a href="http://...." target="nameNotInCurrentFrameset">something</a Thanks Novice
4
2295
by: z. f. | last post by:
Hi, I'm having an aspx page with a server form. i have a grid with a delete button and below the grid, another area with inputs for inserting new values and an "add" button for submiting the lower area of the form. on the lower area i have validators for validating input.
3
1587
by: simon | last post by:
Hi, I was wondering how you include an asp.net button inside an xsl transform file. I want to put a button next to each entry when i style my xml data. Thanks in advance, Simon
2
4085
by: Ed Chiu | last post by:
Hi, I would like to add a <asp:button> to a webform. When user click on this button, the page will connect to SQL server and update tables, then the browser window will be closed. I know how to connect to SQL server and update tables but I don't know how to close browser window after that. The SQL server part is on the server side, closing window is on client side.
8
3904
by: tatemononai | last post by:
I had a beautiful script that was running, well, just beautifully. But then I decided to take a button that fired an event and place it inside a <asp:table. The event WILL NOT FIRE INSIDE THE TABLE!?! When I move the button outside the table, it works just fine. Inside the table, it doesn't. What gives?
4
1750
by: Roy | last post by:
Ok, I feel silly asking this because it seems like such a simple thing but I haven't been able to figure it out. Is it possible to create an asp:button that functions just like an asp:linkbutton? What I'm trying to do is when a user clicks a button (a pushbutton) it will open a new page (not response.redirect but an entirely different browser window). Seems simple, but the answer evades me. :(
3
1984
by: needin4mation | last post by:
Hi, I have an asp:button that has a ShowModalDialog script attribute added to it. When the ShowModalDialog opens the user is supposed to select some data which is then sent back to the calling .aspx page and that data sent back is placed in a hidden textbox for processing when the form posts back from the asp:button (the same button that called the ShowModalDialog windows, calls the window and then postsback). This works fine.
1
4927
by: mazdotnet | last post by:
Hi all, I'm really stuck trying to figure the following out. I have been working on a shopping portal where you can select products from a list inside a repeater on the bottom of the page and on each row, once clicked you can enter a quantity and add it to your cart automatically on top (using UpdatePanel). Everything seems to be working fine when I created a dummy DataTable and did a bind but now that I'm actually reading the contents...
0
9993
marktang
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, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9839
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,...
0
11256
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...
0
10857
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10481
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
9658
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 projectplanning, coding, testing, and deploymentwithout 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...
0
7187
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
5877
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...
2
4295
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.