Solved

click Image button to open file url

Posted on 2007-12-03
8
4,273 Views
Last Modified: 2012-08-13
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#...

0
Comment
Question by:michael1174
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 21

Expert Comment

by:surajguptha
ID: 20398401
You can open a new window in javascript passing the url constructed from the grid's cells
0
 
LVL 18

Accepted Solution

by:
Elvio Lujan earned 500 total points
ID: 20398406
just use in the itemcommand method a

Response.Redirect("yourfile");
0
 
LVL 2

Author Comment

by:michael1174
ID: 20398452
I'll try your suggestion ,but I do need to open it up in a new window....
0
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
LVL 21

Expert Comment

by:surajguptha
ID: 20398468
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
 
LVL 2

Author Comment

by:michael1174
ID: 20398477
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
 
LVL 8

Expert Comment

by:Chumad
ID: 20398495
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
 
LVL 2

Author Comment

by:michael1174
ID: 20398502
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
 
LVL 18

Assisted Solution

by:Elvio Lujan
Elvio Lujan earned 500 total points
ID: 20398669
use

response.write("<script>window.open('yourFile')</script>")
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question