click Image button to open file url

I have an image button in a datagrid, and I need to open a word document.  Can I specify a file url, and if so, how?  Right now my image button is defined as:

<asp:ImageButton class="Image" id="imgDetails" title="Details" runat="server" CommandName="Details"
src="images/ico_Details.gif"></asp:ImageButton>

and on the ItemCommand event is where I want to specify to open a word document thats name is dependent on a couple cells in the grid:

open file url ""file://path/" + e.Item.Cells[1].Text + e.Item.Cells[3].Text + ".doc";

Can anyone help? trying to write this in asp.net c#...

LVL 2
michael1174Asked:
Who is Participating?
 
Elvio LujanConnect With a Mentor .Net Senior DeveloperCommented:
just use in the itemcommand method a

Response.Redirect("yourfile");
0
 
surajgupthaCommented:
You can open a new window in javascript passing the url constructed from the grid's cells
0
 
michael1174Author Commented:
I'll try your suggestion ,but I do need to open it up in a new window....
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
surajgupthaCommented:
This is how u can open this new window
<INPUT type="button" value="New Window!" onClick="window.open('jex5.htm','mywindow','width=400,height=200,left=0,top=100,screenX=0,screenY=100')">

But the value of the url should also be constructed at run time using javascript.. By using javascript you prevent an unnecessary round trip to the server.
0
 
michael1174Author Commented:
I just tried :

Response.Redirect("//file:////path/" + e.Item.Cells[1].Text + e.Item.Cells[3].Text + ".doc");

and it didn't work, it gave me local host and the aspx that I was on...
0
 
ChumadCommented:
Can you change it to a standard img and not use a built in button? Problem you'll run into is outputting javascript from an onclick event (it's doable, but messy.) Instead, you could do something like this:

<a href='<%# String.Format("file://path/{0}", Bind("fieldName"))  %>'><img src='images/ico_Details.gif'></a>
0
 
michael1174Author Commented:
surajguptha, I need those valus in the grid cells in order to construct the name of the documnet, so how can i get the values at runtime?
0
 
Elvio LujanConnect With a Mentor .Net Senior DeveloperCommented:
use

response.write("<script>window.open('yourFile')</script>")
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.