473,406 Members | 2,345 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

OnSelectedIndexChanged - New Browser Window

I have a DataGrid which contains 1 visible column which is a LinkButton:

<Columns>
<asp:BoundColumn DataField="ProductId"
Visible="False"></asp:BoundColumn>
<asp:BoundColumn DataField="DownloadURL"
Visible="False"></asp:BoundColumn>
<asp:TemplateColumn>
<ItemTemplate>
<asp:LinkButton ID="lnkArticle" Runat="server"
Text='<%#DataBinder.Eval(Container, "DataItem.Title")%>'
CommandName="Select" />
</ItemTemplate>
</asp:TemplateColumn>
</Columns>

The data source is a table of PDF files. It contains the Id, the path to the
file, and the title of the file. On the SelectCommand event of the DataGrid,
all I'm doing is streaming the PDF file to the browser:

protected void dgReader_OnSelectedIndexChanged(object sender,
System.EventArgs e){
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "application/pdf";
Response.WriteFile(dgReader.SelectedItem.Cells[1].Text);
Response.Flush();
Response.Close();
}

When I click the select button, I'd like the streaming of the PDF to happen
in a new window.

One very important thing is that I can't pass a query string in the URL (to
prevent URL tampering). Of course, I could do this with a Guid if that's
what it came down to.

Thanks a million for your help
Nov 18 '05 #1
1 1449
"George Durzi" <gd****@hotmail.com> wrote in message
news:ut*************@tk2msftngp13.phx.gbl...
I have a DataGrid which contains 1 visible column which is a LinkButton:

<Columns>
<asp:BoundColumn DataField="ProductId"
Visible="False"></asp:BoundColumn>
<asp:BoundColumn DataField="DownloadURL"
Visible="False"></asp:BoundColumn>
<asp:TemplateColumn>
<ItemTemplate>
<asp:LinkButton ID="lnkArticle" Runat="server"
Text='<%#DataBinder.Eval(Container, "DataItem.Title")%>'
CommandName="Select" />
</ItemTemplate>
</asp:TemplateColumn>
</Columns>

The data source is a table of PDF files. It contains the Id, the path to the file, and the title of the file. On the SelectCommand event of the DataGrid, all I'm doing is streaming the PDF file to the browser:

protected void dgReader_OnSelectedIndexChanged(object sender,
System.EventArgs e){
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "application/pdf";
Response.WriteFile(dgReader.SelectedItem.Cells[1].Text);
Response.Flush();
Response.Close();
}

When I click the select button, I'd like the streaming of the PDF to happen in a new window.


You can't create a new window from the server. Only the client can do that.

Instead of the LinkButton, you could use a HyperLink, with Target="_blank".
Use a GUID in the query string of the URL, and have the newly-requested page
translate that GUID into the PDF file which the second page would stream.
--
John Saunders
johnwsaundersiii at hotmail
Nov 18 '05 #2

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

Similar topics

13
by: Kai Grossjohann | last post by:
It seems that Ctrl-N in Mozilla opens a new empty browser window. That's fine, I don't need to do anything about it. But Ctrl-N in IE appears to clone the current window. Is there a way to...
12
by: Kepler | last post by:
How do you get the height of the client browser in IE? Both document.body.clientHeight and document.body.offsetHeight return the height of the document. If the page is long and there's a vertical...
33
by: randau | last post by:
Linking to a Targeted Browser Window I'd like to open reference links to other web sites in a separate browser window from the browser window hosting my own web site pages. The Link Target...
6
by: G Dean Blake | last post by:
in my aspx app I am writing a stream that works fine but it replaces what is in the client browser window. The code is as follows: .. .. HttpContext.Current.Response.ClearHeaders()...
1
by: Paul L | last post by:
Hi, I have an issue with the OnSelectedIndexChanged event not firing for a DropDownList control which is in the ItemTemplate of a DataList. I have made an exact copy of the DropDownList control,...
2
by: glenn | last post by:
Hi folks, I am trying to determine which item in a DropDownList Web control has been selected. I have posted an OnSelectedIndexChanged subroutine in my code with a reference to the subroutine...
1
by: Groove | last post by:
I have a strange problem. It seems that for some reason, a OnSelectedIndexChanged event is no producing an error in IE6. What concerns me is that I just performed that large Windows update a...
0
by: Groove | last post by:
(repost!) I have a simple and common scenario. I'm developing pages in VWD and FTP-ing them over to a test servr running Window 2003, NET2 Framework. On my page, I have a DDL that causes a...
0
by: toeffetommy | last post by:
Hello, I need a piece of functionality developed for our Website and I need some technical advice on how get there. Essentially, what I want to develop is a browser-within-browser...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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...
0
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...

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.