tags:

views:

2289

answers:

8

Hi

Im new into that asp.net thing, but here goes.

I got at ImageButton, and when its clicked i want the image displayed in another window. If I can avoid using ajax i would like to do that. If possible would like to make the window modal, but still avoid ajax, since Im not ready to mix more technolgies yet.

A: 

Somewhat like this:

<asp:ImageButton ID="imbJoin" CssClass="btn-find" AlternateText="Find" ToolTip="Find" runat="server" ImageUrl="~/library/btn-find.gif" onClick="javascript:popUp("ServicesLocator.aspx")" />

Resource: http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_22832169.html

Using the ImageButton you need to use a JavaScript to open it in a new window. You can also look into the OnClientClick-event

Filip Ekberg
A: 

You can use the ImageButton's OnClientClick property:

<asp:ImageButton ... OnClientClick="javascript:window.open('url_to_image');" >

But this popup window will not be modal.

M4N
A: 

The following javascript will do what you're looking for:

window.open('page.html','WindowTitle','width=400,height=200')
Gavin Miller
+2  A: 

The existing answers with JavaScript are fine, but just to suggest an alternative - could you use a HyperLink (with an ImageUrl set so you still get an image) and set its Target property instead?

Jon Skeet
I like this better, since it wont involve any javascript. +1
Filip Ekberg
A: 

IMHO the best practice to show a picture is in the same page on the top of the content. I personally use Lightbox. You can find the documentation on their page, so it should be easy for you to integrate their JavaScript code.

Germstorm
A: 

It might be worth pointing to a two relevant entries in the excellent EFNet's #javascript FAQ:

  1. Correct Use of Popups - yay accessibility!
  2. How do I make a popup window the same size as my image?
  3. How do I create a custom 'OK' dialog or something similar? - modal windows are not that useful and something like the suggested Lightbox or similar scripts would be better "modal" options
  4. Correct Use of Links - this one being only partly on-topic but the previous answers use of the "javascript:" pseudo protocol made it necessary: it is never required nor useful in a web page that should work across browsers. After all, JavaScript is the default (and only) scripting language.
Bjoern
A: 

Thank you for all the answers! I ended up using lightbox I found this example http://neutrongenious.spaces.live.com/Blog/cns!61E3517BD730D0C7!196.entry

And it works perfectly

CruelIO
A: 

window.showModalDialog('ApproveUsers.aspx?IdCourse={0}&UserIds={1}', 'windowName', 'options');", idCourse, IdUser))

Archana
This has too many closing parenthesis and it seems like part of the code is missing...
sth